001 package nl.tudelft.tbm.eeni.owl2java.model.jmodel;
002
003 import nl.tudelft.tbm.eeni.owl2java.model.jmodel.utils.LogUtils;
004 import nl.tudelft.tbm.eeni.owl2java.utils.IReporting;
005 import org.apache.commons.logging.Log;
006 import org.apache.commons.logging.LogFactory;
007
008
009 public class JAllValuesRestriction extends JBaseRestriction implements IReporting {
010
011 private static Log log = LogFactory.getLog(JAllValuesRestriction.class);
012
013 protected JClass allValues = null;
014
015 // AllValues restrictions of parent classes are deprecated in PropertyRepresentation aggregation step
016 public JAllValuesRestriction(JClass onClass, JProperty onProperty) {
017 super(onClass, onProperty);
018 }
019
020 public boolean equals(Object other) {
021 if (!(other instanceof JAllValuesRestriction))
022 return false;
023 JAllValuesRestriction ar = (JAllValuesRestriction) other;
024 if (!(isEmpty == ar.isEmpty))
025 return false;
026 if (!(allValues.equals(ar.allValues)))
027 return false;
028 return true;
029 }
030
031 public JAllValuesRestriction clone() {
032 JAllValuesRestriction r = new JAllValuesRestriction(onClass, onProperty);
033 r.isEmpty = isEmpty;
034 r.allValues = allValues;
035 return r;
036 }
037
038 @Override
039 public String getJModelReport() {
040 return (LogUtils.toLogName(this) + ": AllValues set to class " + LogUtils.toLogName(allValues));
041 }
042
043 public void setAllValues(JClass cls) {
044 isEmpty = false;
045 if (allValues != null)
046 log.warn(LogUtils.toLogName(this) + ": AllValues already set. Overwriting it with "
047 + LogUtils.toLogName(cls) + "!");
048 allValues = cls;
049 }
050
051 public boolean hasAllValues() {
052 return (!(allValues == null));
053 }
054
055 public JClass getAllValues() {
056 return allValues;
057 }
058
059 }