javapartial-classes

A way to implement partial classes in java


I have an interface that I want to implement in separate classes after doing a quick google search apparently, Java doesn't have partial classes. Is there a way that I can do this or am I stuck throwing all of my code into one class?

Basically, I am trying to write a service. Some of the service methods really belong in their own class and seem kind of illogical in the same class. Here is an example of what I am trying to do.

package com.upmc.esdm.messaging.epcd.service;
import java.util.List;

import javax.ejb.Remote;

import com.upmc.esdm.messaging.epcd13jpa.entities.EmailDomainTrust;


@Remote
public interface MessagingInterfaceRemote {
public List<EmailDomainTrust> getEmailDomains();

    public int upDateQualityTable();

    public string isLogial();

    public byte[] ToWritePartialClassesInJava();
}

I would normally have partial classes in C# and I would put similar methods that return similar values into one partial class (or maybe classes that update a record in one class). How would I implement this? Or should I just put all the method implementations into one class?

Thanks.


Solution

  • There is nothing like partial classes in Java. You can achieve many of the same benefits using aggregation, delegation, and abstract base classes.