Example #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;
  }
Example #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();
  }