/** Returns the name for a ResourceName for the resource of the given method. */ public static Name getResourceNameName(ResourceNameConfig resourceNameConfig) { return Name.anyCamel(resourceNameConfig.getEntityName()).join("name"); } }
@Override protected Name getResourceTypeNameObject(ResourceNameConfig resourceNameConfig) { String entityName = resourceNameConfig.getEntityName(); ResourceNameType resourceNameType = resourceNameConfig.getResourceNameType(); // Proto annotations use UpperCamelCase for resource names, // and GAPIC config uses lower_snake_case, so we have to support both formats. Function<String, Name> formatNameFunc; if (entityName.length() > 0 && Character.isUpperCase(entityName.charAt(0))) { formatNameFunc = Name::upperCamel; } else { formatNameFunc = Name::anyLower; } switch (resourceNameType) { case ANY: return getAnyResourceTypeName(); case FIXED: return formatNameFunc.apply(entityName).join("name_fixed"); case ONEOF: // Remove suffix "_oneof". This allows the collection oneof config to "share" an entity name // with a collection config. entityName = StringUtil.removeSuffix(entityName, "_oneof"); return formatNameFunc.apply(entityName).join("name"); case SINGLE: return formatNameFunc.apply(entityName).join("name"); case NONE: default: throw new UnsupportedOperationException("unexpected entity name type"); } }
protected Name getResourceTypeNameObject(ResourceNameConfig resourceNameConfig) { String entityName = resourceNameConfig.getEntityName(); ResourceNameType resourceNameType = resourceNameConfig.getResourceNameType(); // Proto annotations use UpperCamelCase for resource names, // and GAPIC config uses lower_snake_case, so we have to support both formats. Function<String, Name> formatNameFunc; if (entityName.length() > 0 && Character.isUpperCase(entityName.charAt(0))) { formatNameFunc = Name::upperCamel; } else { formatNameFunc = Name::anyLower; } switch (resourceNameType) { case ANY: return getAnyResourceTypeName(); case FIXED: return Name.anyLower(entityName).join("name_fixed"); case ONEOF: // Remove suffix "_oneof". This allows the collection oneof config to "share" an entity name // with a collection config. entityName = StringUtil.removeSuffix(entityName, "_oneof"); return formatNameFunc.apply(entityName).join("name_oneof"); case SINGLE: return formatNameFunc.apply(entityName).join("name"); case NONE: default: throw new UnsupportedOperationException("unexpected entity name type"); } }