/** * Another satisfy for continuous data types. Indicates whether a particular value is higher or * lower (as specified by theDirection) than the upper or lower threshold. * * <p> * * @param theGeneticDataType * @return true if the value is satisfied by the specified inequalities in the spec */ public boolean satisfy(GeneticDataTypes theGeneticDataType, float value, Direction theDirection) throws IllegalArgumentException { if (!theGeneticDataType.getTheDataTypeCategory().equals(DataTypeCategory.Continuous)) { throw new IllegalArgumentException( "satisfy for continuous data types only takes continuous GeneticDataTypes"); } ResultDataTypeSpec theResultDataTypeSpec = finalDataTypeSpecs.get(theGeneticDataType); if (null == theResultDataTypeSpec) { return false; } if (theResultDataTypeSpec.acceptAll) { return true; } switch (theDirection) { case higher: return (theResultDataTypeSpec.combinedGreaterContinuousDataTypeSpec != null && finalDataTypeSpecs .get(theGeneticDataType) .combinedGreaterContinuousDataTypeSpec .satisfy(value)); case lower: return (theResultDataTypeSpec.combinedLesserContinuousDataTypeSpec != null && finalDataTypeSpecs .get(theGeneticDataType) .combinedLesserContinuousDataTypeSpec .satisfy(value)); } // unreachable code; keep compiler happy // TODO: throw an exception return false; }
/** * satisfy for continuous data types. * * @param theGeneticDataType * @return true if the value is in one of the inequalities passed by the spec */ public boolean satisfy(GeneticDataTypes theGeneticDataType, float value) throws IllegalArgumentException { if (theGeneticDataType.getTheDataTypeCategory().equals(DataTypeCategory.Discrete)) { throw new IllegalArgumentException( "satisfy for continuous data types only takes continuous GeneticDataTypes"); } ResultDataTypeSpec theResultDataTypeSpec = finalDataTypeSpecs.get(theGeneticDataType); if (null == theResultDataTypeSpec) { return false; } if (theResultDataTypeSpec.acceptAll) { return true; } if (theResultDataTypeSpec.combinedLesserContinuousDataTypeSpec != null && finalDataTypeSpecs .get(theGeneticDataType) .combinedLesserContinuousDataTypeSpec .satisfy(value)) { return true; } if (theResultDataTypeSpec.combinedGreaterContinuousDataTypeSpec != null && finalDataTypeSpecs .get(theGeneticDataType) .combinedGreaterContinuousDataTypeSpec .satisfy(value)) { return true; } return false; }
@Override public String toString() { StringBuffer sb = new StringBuffer(); for (GeneticDataTypes aGeneticDataTypes : GeneticDataTypes.values()) { // out.format("checking %s%n", aGeneticDataTypes); ResultDataTypeSpec theResultDataTypeSpec = this.finalDataTypeSpecs.get(aGeneticDataTypes); if (null != theResultDataTypeSpec) { // out.format(" for gt %s%n", aGeneticDataTypes); sb.append(theResultDataTypeSpec.toString()).append(" "); } } return sb.append(";").toString(); }
/** * satisfy for discrete data types. * * @param theGeneticDataType * @param theGeneticTypeLevel * @return indicates whether this display spec classifies the given data types' level as an * alteration * @throws IllegalArgumentException */ public boolean satisfy( GeneticDataTypes theGeneticDataType, Object level) // GeneticTypeLevel theGeneticTypeLevel ) throws IllegalArgumentException { if (!theGeneticDataType.getTheDataTypeCategory().equals(DataTypeCategory.Discrete)) { throw new IllegalArgumentException( "satisfy for discrete data types only takes Discrete GeneticDataTypes"); } ResultDataTypeSpec theResultDataTypeSpec = finalDataTypeSpecs.get(theGeneticDataType); if (null == theResultDataTypeSpec) { return false; } if (theResultDataTypeSpec.acceptAll) { return true; } if (theResultDataTypeSpec.theDiscreteDataTypeSetSpec != null && theResultDataTypeSpec.theDiscreteDataTypeSetSpec.satisfy(level)) { return true; } return false; }