All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cdc.mf.model.MfTipRole Maven / Gradle / Ivy

The newest version!
package cdc.mf.model;

import cdc.util.lang.UnexpectedValueException;

public enum MfTipRole {
    SOURCE(MfTipSide.SOURCE, "source"),
    TARGET(MfTipSide.TARGET, "target"),
    WHOLE(MfTipSide.SOURCE, "whole"),
    PART(MfTipSide.TARGET, "part");

    private final MfTipSide side;
    private final String literal;

    private MfTipRole(MfTipSide side,
                      String literal) {
        this.side = side;
        this.literal = literal;
    }

    public MfTipSide getSide() {
        return side;
    }

    public String getLiteral() {
        return literal;
    }

    public boolean isCompliantWith(MfConnector connector) {
        return isCompliantWith(connector.getClass());
    }

    public boolean isCompliantWith(Class connectorClass) {
        switch (this) {
        case PART, WHOLE:
            return connectorClass.equals(MfAggregation.class) || connectorClass.equals(MfComposition.class);
        case SOURCE, TARGET:
            return true;
        default:
            throw new UnexpectedValueException(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy