private static <T> ItemSpec<T> create(String key, Type type, @Nullable T value) { return ItemSpec.<T>builder().setKey(key).setType(type).setRawValue(value).build(); }
ItemSpec.Builder<T> setRawValue(@Nullable T value) { FormattedItemValue formatted = getType().safeFormat(value); return this.setValue(formatted.getLongValue()).setShortValue(formatted.getShortValue()); } }
/** * Set the item {@link Item#getLabel() label}. * * <p>Specifying a null value will clear the label if it was previously defined. * * <p>This method does not alter the current instance, but instead returns a new {@link * ItemSpec} with the label set. */ public ItemSpec<T> withLabel(@Nullable String label) { return toBuilder().setLabel(label).build(); }
/** * Set the item {@link Item#getLinkUrl() link url}. * * <p>Specifying a null value will clear the link url if it was previously defined. * * <p>This method does not alter the current instance, but instead returns a new {@link * ItemSpec} with the link url set. */ public ItemSpec<T> withLinkUrl(@Nullable String url) { return toBuilder().setLinkUrl(url).build(); }
/** * Set the item {@link ItemSpec#getNamespace() namespace} from the given {@link Class}. * * <p>This method does not alter the current instance, but instead returns a new {@link * ItemSpec} with the namespace set. */ public ItemSpec<T> withNamespace(Class<?> namespace) { checkNotNull(namespace, "namespace argument cannot be null"); return toBuilder().setNamespace(namespace).build(); }
/** * Creates a similar item to the current instance but with the specified value. * * <p>This should only be used internally. It is useful to compare the value of a {@link * DisplayData.Item} to the value derived from a specified input. */ private ItemSpec<T> withValue(T value) { return toBuilder().setRawValue(value).build(); }