/** * Checks if the struct member with the given name should be represented in the XML schema as an attribute instead * of an nested element. Currently this is necessary for the {@code id} and {@code href} attribute. * * @param name the name to check * @return {@code true} if the attribute with the given name should be represented as an XML attribute, * {@code false} otherwise */ public boolean isRepresentedAsAttribute(Name name) { return HREF.equals(name) || ID.equals(name) || REL.equals(name); } }
/** * Generates a string representation of this annotation, usually just its name. */ @Override public String toString() { return name != null? name.toString(): ""; }
/** * Decorates a name with optional prefix and suffix. */ private Name decorateName(Name name, Name prefix, Name suffix) { List<String> words = name.getWords(); if (prefix != null) { words.addAll(0, prefix.getWords()); } if (suffix != null) { words.addAll(suffix.getWords()); } return new Name(words); } }
/** * Separates the given text into words, using the given separator character, and creates a new name containing * those words. For example, to convert the text {@code my_favorite_fruit} into a name the method can be used * as follows: * * <pre> * Name name = parseUsingSeparator("my_favorite_fruit", '_'); * </pre> * * @param text the text to process * @param separator the character that separates words * @return the name composed of the words extracted from the text */ public static Name parseUsingSeparator(String text, char separator) { Name name = new Name(); String[] words = text.split("[" + separator + "]"); for (String word : words) { name.addWord(word); } return name; }
private String getEnumValueLine(EnumValue enumValue, boolean lastValue) { String value = join("_", enumValue.getName().getWords()).toUpperCase(); return value + (lastValue ? ";" : ","); }
/** * Compares this object to another named object. Only the name is taken into account for this comparison, and the * result is intended only for sorting concepts by name. In particular if the result is 0 it only means that * both objects have the same name, not that they are equal. */ @Override default int compareTo(Named that) { Name thisName = this.getName(); Name thatName = that.getName(); if (thisName == null && thatName != null) { return -1; } if (thisName == null) { return 0; } if (thatName == null) { return 1; } return thisName.compareTo(thatName); }
for (MemberInvolvementTree attribute : parameter.getMandatoryAttributes()) { List<MemberInvolvementTree> attributeComponents = stackAttributeComponents(attribute); MemberInvolvementTree component = new MemberInvolvementTree(new Name(parameter.getName())); component.setType(parameter.getType()); attributeComponents.add(0, component);
/** * Computes a hash code for this annotation parameter. Only the name is taken into account for this computation, the * value is ignored. */ @Override public int hashCode() { if (name != null) { return name.hashCode(); } return super.hashCode(); } }
public Name shallowToString() { Stack<Name> stack = new Stack<>(); MemberInvolvementTree memberInvolvementTree = this; stack.push(memberInvolvementTree.getName()); while (memberInvolvementTree.hasParent()) { memberInvolvementTree = memberInvolvementTree.getParent(); stack.push(memberInvolvementTree.getName()); } Name name = new Name(); while (!stack.isEmpty()) { name.addWords(stack.pop().getWords()); } return name; }
/** * Separates the given text into words, using the case transitions as separators, and creates a new name containing * those words. * * @param text the text to process */ public static Name parseUsingCase(String text) { Name name = new Name(); StringBuilder wordBuffer = new StringBuilder(); for (char current : text.toCharArray()) { if (Character.isUpperCase(current)) { if (wordBuffer.length() > 0) { name.addWord(wordBuffer.toString()); wordBuffer.setLength(0); } } wordBuffer.append(current); } if (wordBuffer.length() > 0) { name.addWord(wordBuffer.toString()); } return name; } }
private Name combineAlternatives(MemberInvolvementTree attribute) { Name name1 = attribute.shallowToString(); Name name2 = attribute.getAlternative().shallowToString(); if (name1.compareTo(name2) < 0) { return names.concatenate(name1, name2); } else { return names.concatenate(name2, name1); } } }
/** * Computes a hash code for this concept. Only the name is taken into account for this computation, the * documentation and the source are ignored. */ @Override public int hashCode() { if (name != null) { return name.hashCode(); } return super.hashCode(); } }
private void generateActionSignature(Method method) { generateDoc(method); javaBuffer.addImport(Response.class); javaBuffer.addImport(javaPackages.getXjcPackageName(), "Action"); Name methodName = new Name(method.getBase().getName()); methodName.addWords(method.getName().getWords()); javaBuffer.addLine("default public Response %s(Action action) {", jaxrsNames.getMethodName(methodName)); javaBuffer.addLine("throw new UnsupportedOperationException();"); javaBuffer.addLine("}"); }
/** * Remove tree with provided root name from member-involvement-trees list. */ public void removeMemeberInvolvementTree(Name name) { memberInvolvementTrees.removeIf(s -> s.getName().equals(name)); }