/** * Returns a new Name containing the pieces from this Name plus the pieces of the given name added * on the end. */ public Name join(Name rhs) { List<NamePiece> newPieceList = new ArrayList<>(); newPieceList.addAll(namePieces); newPieceList.addAll(rhs.namePieces); return new Name(newPieceList); }
/** * Returns a new Name containing the pieces from this Name plus the given identifier added on the * end. */ public Name join(String identifier) { validateLowerUnderscore(identifier); List<NamePiece> newPieceList = new ArrayList<>(); newPieceList.addAll(namePieces); newPieceList.add(new NamePiece(identifier, CaseFormat.LOWER_UNDERSCORE)); return new Name(newPieceList); }
/** * Creates a Name from a sequence of upper-underscore strings. * * @throws IllegalArgumentException if any of the strings contain any characters that are not * upper case or underscores. */ public static Name upperUnderscore(String... pieces) { List<NamePiece> namePieces = new ArrayList<>(); for (String piece : pieces) { if (Strings.isNullOrEmpty(piece)) { continue; } validateUpperUnderscore(piece); namePieces.add(new NamePiece(piece, CaseFormat.UPPER_UNDERSCORE)); } return new Name(namePieces); }
/** * Creates a Name from a sequence of lower-underscore strings. * * @throws IllegalArgumentException if any of the strings contain any characters that are not * lower case or underscores. */ public static Name from(String... pieces) { List<NamePiece> namePieces = new ArrayList<>(); for (String piece : pieces) { if (Strings.isNullOrEmpty(piece)) { continue; } validateLowerUnderscore(piece); namePieces.add(new NamePiece(piece, CaseFormat.LOWER_UNDERSCORE)); } return new Name(namePieces); }
private static Name camelInternal( CheckCase checkCase, AcronymMode acronymMode, String... pieces) { List<NamePiece> namePieces = new ArrayList<>(); for (String piece : pieces) { if (Strings.isNullOrEmpty(piece)) { continue; } validateCamel(piece, checkCase); for (SubNamePiece subPiece : CommonAcronyms.splitByUpperAcronyms(piece)) { CaseFormat caseFormat = getCamelCaseFormat(subPiece.namePieceString()); CasingMode casingMode = CasingMode.NORMAL; if (subPiece.type().equals(NamePieceCasingType.UPPER_ACRONYM)) { caseFormat = CaseFormat.UPPER_UNDERSCORE; casingMode = acronymMode.casingMode; } namePieces.add(new NamePiece(subPiece.namePieceString(), caseFormat, casingMode)); } } return new Name(namePieces); }