@Override public String asString() { return getRawValue(); }
@Override public boolean isSet() { return getRawValue() != null; }
@Override public ControllerService asControllerService() { if (getRawValue() == null || getRawValue().equals("") || serviceLookup == null) { return null; } return serviceLookup.getControllerService(getRawValue()); }
@Override public Long asLong() { return (getRawValue() == null) ? null : Long.parseLong(getRawValue().trim()); }
@Override public Float asFloat() { return (getRawValue() == null) ? null : Float.parseFloat(getRawValue().trim()); }
@Override public Boolean asBoolean() { return (getRawValue() == null) ? null : Boolean.parseBoolean(getRawValue().trim()); }
@Override public Integer asInteger() { return (getRawValue() == null) ? null : Integer.parseInt(getRawValue().trim()); }
@Override public Double asDouble() { return (getRawValue() == null) ? null : Double.parseDouble(getRawValue().trim()); }
@Override public <T extends ControllerService> T asControllerService(final Class<T> serviceType) throws IllegalArgumentException { if (!serviceType.isInterface()) { throw new IllegalArgumentException("ControllerServices may be referenced only via their interfaces; " + serviceType + " is not an interface"); } if (getRawValue() == null || getRawValue().equals("") || serviceLookup == null) { return null; } final ControllerService service = serviceLookup.getControllerService(getRawValue()); if (service == null) { return null; } if (serviceType.isAssignableFrom(service.getClass())) { return serviceType.cast(service); } throw new IllegalArgumentException("Controller Service with identifier " + getRawValue() + " is of type " + service.getClass() + " and cannot be cast to " + serviceType); }
@Override public Record asRecord() { return (getRawValue() == null) ? null : new StandardRecord() .setStringField(FieldDictionary.RECORD_VALUE,getRawValue().trim()); }