Skip to content

Commit

Permalink
removed property from generation
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Dec 31, 2017
1 parent 627102d commit 8d71302
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ static String getName( Class<?> type ) {
* @return
* @throws ClassNotFoundException
*/
static String getName( Type type, Class<?> declaringClass ) throws ClassNotFoundException {
static String getName( Type type, Class<?> declaringClass, boolean packageResolution ) throws ClassNotFoundException {

final Class<?> clazz = Class.forName(type.getTypeName());

return getName( clazz, declaringClass );
return getName( clazz, declaringClass, packageResolution );

}

Expand Down
59 changes: 33 additions & 26 deletions processor/src/main/java/org/bsc/processor/TypescriptProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private String getPropertyDecl( Class<?> declaringClass,
final String typeName = pClass.getTypeName();

try {
final String name = getName( pClass, pd.getPropertyType());
final String name = getName( pClass, pd.getPropertyType(), true);

final String r = rType.getTypeName()
.replaceAll(typeName, name)
Expand Down Expand Up @@ -504,7 +504,20 @@ private String processClass( BeanInfo bi, java.util.Map<String, Class<?>> decla

final StringBuilder sb = new StringBuilder();

final PropertyDescriptor[] pds = bi.getPropertyDescriptors();
final String namespace = type.getPackage().getName();

if( !type.isMemberClass() )
sb.append( "declare namespace " )
.append(namespace)
.append(" {\n\n")
;

sb.append( getClassDecl(type, declaredClassMap) )
.append("\n\n");

processEnum(sb, type, declaredClassMap);

//final PropertyDescriptor[] pds = bi.getPropertyDescriptors();

final java.util.Set<Method> methodSet =
getMethods( type )
Expand All @@ -513,37 +526,31 @@ private String processClass( BeanInfo bi, java.util.Map<String, Class<?>> decla
.filter( (md) -> {
final String name = md.getName();
return !( name.contains("$") || // remove unnamed
name.equals("getClass") ||
name.equals("hashCode") ||
name.equals("wait") ||
name.equals("notify") ||
name.equals("notifyAll") );
})
.filter( md -> // Remove setter and getter
!Arrays.asList(pds)
/*
.filter( md -> {// Remove setter and getter
final boolean match = Arrays.asList(pds)
.stream()
.anyMatch( pd -> (md.equals(pd.getReadMethod()) || md.equals(pd.getWriteMethod())) )
)
//.peek( (md ) -> System.out.printf( "==> CLASS [%s] - METHOD\t[%s]\n",type.getSimpleName(),md.getName()))
.noneMatch( pd -> (md.equals(pd.getReadMethod()) || md.equals(pd.getWriteMethod())) );
return match;
})
*/
.collect( Collectors.toCollection(() -> new java.util.LinkedHashSet<Method>() ));

/*
final java.util.Set<PropertyDescriptor> propertySet =
Arrays.stream(pds)
.filter( TypescriptHelper::isPropertyValid )
.collect( Collectors.toCollection(() -> new java.util.LinkedHashSet<PropertyDescriptor>(pds.length) ))
;
final String namespace = type.getPackage().getName();

if( !type.isMemberClass() )
sb.append( "declare namespace " )
.append(namespace)
.append(" {\n\n")
;

sb.append( getClassDecl(type, declaredClassMap) )
.append("\n\n");

processEnum(sb, type, declaredClassMap);

propertySet.stream()
.map( pd -> {
final boolean duplicate = methodSet.stream().anyMatch( m -> m.getName().equals(pd.getName()));
Expand All @@ -552,12 +559,12 @@ private String processClass( BeanInfo bi, java.util.Map<String, Class<?>> decla
})
.sorted()
.forEach((decl) ->

sb.append( '\t' )
.append(decl)
.append( ENDL ))
;

sb.append( '\t' )
.append(decl)
.append( ENDL ))
;
*/
methodSet.stream()
.map( md -> getMethodDecl(md, type, declaredClassMap) )
.sorted().forEach( (decl) ->
Expand Down

0 comments on commit 8d71302

Please sign in to comment.