Ejemplo n.º 1
0
  public static Object getValue(FL_Property prop) {
    if (prop != null) {
      Object range = prop.getRange();
      if (range == null) return null;

      if (range instanceof FL_SingletonRange) {
        return ((FL_SingletonRange) range).getValue();
      } else if (range instanceof FL_ListRange) {
        return ((FL_ListRange) range).getValues().iterator().next();
      } else if (range instanceof FL_BoundedRange) {
        FL_BoundedRange bounded = (FL_BoundedRange) range;
        return bounded.getStart() != null ? bounded.getStart() : bounded.getEnd();
      } else if (range instanceof FL_DistributionRange) {
        FL_DistributionRange dist = (FL_DistributionRange) range;
        return dist.getDistribution();
      }
    }

    return null;
  }
Ejemplo n.º 2
0
  public List<Object> getValues() {
    Object range = getRange();

    if (range != null) {
      if (range instanceof FL_SingletonRange) {
        return Collections.singletonList(((FL_SingletonRange) range).getValue());
      } else if (range instanceof FL_ListRange) {
        return ((FL_ListRange) range).getValues();
      } else if (range instanceof FL_BoundedRange) {
        FL_BoundedRange bounded = (FL_BoundedRange) range;
        return Arrays.asList(bounded.getStart(), bounded.getEnd());
      } else if (range instanceof FL_DistributionRange) {
        FL_DistributionRange dist = (FL_DistributionRange) range;
        List<Object> values = new ArrayList<Object>(dist.getDistribution().size());
        values.addAll(dist.getDistribution());
        return values;
      }
    }

    return Collections.emptyList();
  }
Ejemplo n.º 3
0
 public PropertyHelper(
     String key,
     String friendlyText,
     Object startValue,
     Object endValue,
     FL_PropertyType type,
     List<FL_PropertyTag> tags) {
   setKey(key);
   setFriendlyText(friendlyText);
   setProvenance(null);
   setUncertainty(null);
   setTags(tags);
   setRange(FL_BoundedRange.newBuilder().setStart(startValue).setEnd(endValue).setType(type));
 }