use of com.google.api.codegen.config.ResourceNameType in project toolkit by googleapis.
the class JavaSurfaceNamer method getResourceTypeNameObject.
@Override
protected Name getResourceTypeNameObject(ResourceNameConfig resourceNameConfig) {
Name entityName = resourceNameConfig.getEntityName();
ResourceNameType resourceNameType = resourceNameConfig.getResourceNameType();
switch(resourceNameType) {
case ANY:
return getAnyResourceTypeName();
case FIXED:
return 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 = Name.from(StringUtil.removeSuffix(entityName.toLowerUnderscore(), "_oneof"));
return entityName.join("name");
case SINGLE:
return entityName.join("name");
case NONE:
default:
throw new UnsupportedOperationException("unexpected entity name type");
}
}
use of com.google.api.codegen.config.ResourceNameType in project toolkit by googleapis.
the class SurfaceNamer method getResourceTypeNameObject.
protected Name getResourceTypeNameObject(ResourceNameConfig resourceNameConfig) {
Name entityName = resourceNameConfig.getEntityName();
ResourceNameType resourceNameType = resourceNameConfig.getResourceNameType();
switch(resourceNameType) {
case ANY:
return getAnyResourceTypeName();
case FIXED:
return 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 = Name.from(StringUtil.removeSuffix(entityName.toLowerUnderscore(), "_oneof"));
return entityName.join("name_oneof");
case SINGLE:
return entityName.join("name");
case NONE:
default:
throw new UnsupportedOperationException("unexpected entity name type");
}
}
use of com.google.api.codegen.config.ResourceNameType in project toolkit by googleapis.
the class JavaModelTypeNameConverter method getResourceNamePackage.
private static String getResourceNamePackage(FieldConfig fieldConfig) {
String commonResourceName = fieldConfig.getResourceNameConfig().getCommonResourceName();
if (commonResourceName != null) {
// Common resource name is fully-qualified.
int p = commonResourceName.lastIndexOf(".");
if (p >= 0) {
commonResourceName = commonResourceName.substring(0, p);
}
return commonResourceName;
}
ResourceNameType resourceNameType = fieldConfig.getResourceNameConfig().getResourceNameType();
switch(resourceNameType) {
case ANY:
return "com.google.api.resourcenames";
case FIXED:
case SINGLE:
case ONEOF:
ProtoFile assignedProtoFile = fieldConfig.getResourceNameConfig().getAssignedProtoFile();
if (assignedProtoFile == null) {
FieldModel fm = fieldConfig.getField();
assignedProtoFile = ((ProtoField) fm).getProtoField().getFile();
}
return getJavaPackage(assignedProtoFile);
case NONE:
default:
throw new IllegalArgumentException("Unexpected ResourceNameType: " + resourceNameType);
}
}
Aggregations