Skip to content

Instantly share code, notes, and snippets.

@eiswind
Last active May 6, 2017 11:38
Show Gist options
  • Save eiswind/9abfda4e365a1626bc329395017f27de to your computer and use it in GitHub Desktop.
Save eiswind/9abfda4e365a1626bc329395017f27de to your computer and use it in GitHub Desktop.
mapstruct with protobuf3
public class Proto3AccessorNamingStrategy
extends DefaultAccessorNamingStrategy {
@Override
public String getElementName(ExecutableElement adderMethod) {
String methodName =
adderMethod.getSimpleName().toString() + "List";
return Introspector.decapitalize(methodName.substring(3));
}
}
@Mapper(uses = BuilderFactory.class,
collectionMappingStrategy =
CollectionMappingStrategy.ADDER_PREFERRED)
public interface LoginServerMapper {
LoginServerMapper MAPPER = Mappers.getMapper(LoginServerMapper.class);
@Mapping(source = "permissions", target = "permissionsList")
LoginResponseDTO.Builder map(LoginResult result);
PermissionDTO map(Permission permission);
class BuilderFactory {
public LoginResponseDTO.Builder create() {
return LoginResponseDTO.newBuilder();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment