com.abubusoft.kripton.processor.bind.BinderMapRegistry Maven / Gradle / Ivy
package com.abubusoft.kripton.processor.bind;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.abubusoft.kripton.common.Pair;
import com.abubusoft.kripton.processor.core.reflect.TypeUtility;
import com.google.common.base.CaseFormat;
import com.google.common.base.Converter;
import com.squareup.javapoet.TypeName;
/**
* Binding Map Registry
* @author xcesco
*
*/
public class BinderMapRegistry
{
/* ordered set of binder needed for model */
private Map> registry=new HashMap>();
private final static BinderMapRegistry instance=new BinderMapRegistry();
public static BinderMapRegistry getInstance() {
return instance;
}
public void registry(TypeName binderTypeName, TypeName typeName) {
Set entry = registry.get(binderTypeName);
if (entry==null) {
entry=new HashSet<>();
registry.put(binderTypeName, entry);
}
entry.add(typeName);
}
public Pair getMapperNames(TypeName typeName) {
Converter format = CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.LOWER_CAMEL);
TypeName bindMapperName=TypeUtility.mergeTypeNameWithSuffix(typeName,BindTypeBuilder.SUFFIX);
String simpleName=format.convert(TypeUtility.simpleName(bindMapperName));
Pairresult=Pair.of(simpleName, bindMapperName);
return result;
}
public Set getEntityEntries(TypeName entityType) {
return registry.get(entityType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy