public boolean shouldExpand(Expandable expandable) { return parameters.containsKey(WILDCARD) || parameters.containsKey(Preconditions.checkNotNull(expandable).value()); }
public Indexes getIndexes(Expandable expandable) { final ExpandInformation expandInformation = parameters.get(Preconditions.checkNotNull(expandable).value()); return expandInformation != null ? expandInformation.getIndexes() : IndexParser.EMPTY; }
public ExpandParameter getExpandParameter(Expandable expandable) { final ExpandInformation wildcardExpandInformation = parameters.get(WILDCARD); final ExpandInformation valueExpandInformation = parameters.get(Preconditions.checkNotNull(expandable).value()); return new ChainingExpandParameter( wildcardExpandInformation != null ? wildcardExpandInformation.getExpandParameter() : EMPTY_EXPAND_PARAMETER, valueExpandInformation != null ? valueExpandInformation.getExpandParameter() : EMPTY_EXPAND_PARAMETER); }
/** * Returns the expandable annotation with the properly set value. The value is defined as the first valid point in the following list: * <ol> * <li>the value of the {@link Expandable} annotation if it is set</li> * <li>the name of an {@link XmlElement} if the annotation is present on the field and its name is not {@code ##default}</li> * <li>the name of the field</li> * <ol> * * @param field the field to look up the Expandable for * @return {@code null} if the field is null, {@code null} if the field doesn't have an expandable annotation, * an expandable annotation with a properly set value. */ Expandable getExpandable(final Field field) { if (field == null) { return null; } final Expandable expandable = field.getAnnotation(Expandable.class); if (expandable == null) { return null; } if (StringUtils.isNotEmpty(expandable.value())) { return expandable; } final XmlElement xmlElement = field.getAnnotation(XmlElement.class); if (xmlElement != null && StringUtils.isNotEmpty(xmlElement.name()) && !StringUtils.equals("##default", xmlElement.name())) { return new ExpandableWithValue(xmlElement.name()); } return new ExpandableWithValue(field.getName()); }