Last active
May 6, 2017 11:38
-
-
Save eiswind/9abfda4e365a1626bc329395017f27de to your computer and use it in GitHub Desktop.
mapstruct with protobuf3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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