/** * Adds the version prefix to the given name. */ private Name addPrefix(Name name) { if (versionPrefix != null && !versionPrefix.isEmpty()) { List<String> words = name.getWords(); words.add(0, versionPrefix); name = new Name(words); } return name; } }
public Name getSingular(Name plural) { List<String> all = plural.getWords(); String last = all.get(all.size() - 1); last = words.getSingular(last); all.set(all.size() - 1, last); return new Name(all); }
public Name getPlural(Name singular) { List<String> all = singular.getWords(); String last = all.get(all.size() - 1); last = words.getPlural(last); all.set(all.size() - 1, last); return new Name(all); }
/** * 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; }
/** * 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; } }
/** * 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); } }
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; }
/** * Returns a new Name, containing the words of both provided names, * in the order in which they were provided. */ public Name concatenate(Name name1, Name name2) { Name name = new Name(name1.getWords()); name.addWords(name2.getWords()); return name; } }
private Name getSignatureDetectionMethodName(Method method) { Name methodName = new Name(); methodName.addWord("get"); methodName.addWords(method.getName().getWords()); methodName.addWord("Signature"); return methodName; }
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("}"); }
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);