persistence icon indicating copy to clipboard operation
persistence copied to clipboard

Common interface for EntityGraph and Subgraph

Open kalgon opened this issue 4 years ago • 0 comments
trafficstars

EntityGraph and Subgraph share a lot of identical methods. Those methods could be declared on a (new) common interface extended by both EG and SG.

public interface Graph<T> {
    void addAttributeNodes(String ... attributeName);
    void addAttributeNodes(Attribute<T, ?> ... attribute);
    <X> Subgraph<X> addSubgraph(Attribute<T, X> attribute);
    <X> Subgraph<? extends X> addSubgraph(Attribute<T, X> attribute, Class<? extends X> type);
    <X> Subgraph<X> addSubgraph(String attributeName);
    <X> Subgraph<X> addSubgraph(String attributeName, Class<X> type);
    <X> Subgraph<X> addKeySubgraph(Attribute<T, X> attribute);
    <X> Subgraph<? extends X> addKeySubgraph(Attribute<T, X> attribute, Class<? extends X> type);
    <X> Subgraph<X> addKeySubgraph(String attributeName);
    <X> Subgraph<X> addKeySubgraph(String attributeName, Class<X> type);
    List<AttributeNode<?>> getAttributeNodes();
}

public interface EntityGraph<T> extends Graph<T> {
    String getName();
    <T> Subgraph<? extends T> addSubclassSubgraph(Class<? extends T> type);
}

public interface Subgraph<T> extends Graph<T> {
    Class<T> getClassType();
}

kalgon avatar Jan 08 '21 15:01 kalgon