use of com.liferay.apio.architect.identifier.Identifier in project com-liferay-apio-architect by liferay.
the class MockWriterUtil method identifierToPath.
/**
* Returns a mock {@link Path} from an identifier. The identifier must be a
* {@link String}, otherwise {@code Optional#empty()} is returned.
*
* @param identifier the identifier
* @return the mock {@code Path} from the identifier, if the identifier is a
* {@code String}; {@code Optional#empty()} otherwise
*/
public static Optional<Path> identifierToPath(String resourceName, Object identifier) {
if (!(identifier instanceof String)) {
return Optional.empty();
}
String string = (String) identifier;
Function<String, Optional<Path>> function = name -> Optional.of(new Path(name, string));
if ("root".equals(resourceName)) {
return function.apply("model");
}
if ("first".equals(resourceName)) {
return function.apply("first-inner-model");
}
if ("second".equals(resourceName)) {
return function.apply("second-inner-model");
}
return function.apply("third-inner-model");
}
use of com.liferay.apio.architect.identifier.Identifier in project com-liferay-apio-architect by liferay.
the class RepresentableManagerImpl method emit.
@Override
protected void emit(ServiceReference<Representable> serviceReference, Emitter<Class<Identifier>> emitter) {
Representable representable = bundleContext.getService(serviceReference);
Class<Identifier> genericClass = getGenericClassFromPropertyOrElse(serviceReference, KEY_PRINCIPAL_TYPE_ARGUMENT, () -> getTypeParamOrFail(representable, Representable.class, 2));
emitter.emit(genericClass);
}
Aggregations