Skip to content

Commit

Permalink
add functional management
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed May 21, 2018
1 parent 170e864 commit e69e29e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
41 changes: 32 additions & 9 deletions core/src/main/java/org/bsc/java2typescript/TSType.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class TSType extends HashMap<String, Object> {
private static final String VALUE = "value";
private static final String EXPORT = "export";
private static final String NAMESPACE = "namespace";
private static final String FUNCTIONAL = "functional";

protected TSType() {
super(3);
Expand Down Expand Up @@ -53,6 +54,7 @@ public static TSType from(Class<?> cl) {
};
}


/**
*
* @return
Expand All @@ -73,8 +75,8 @@ public boolean isExport() {
*
* @return
*/
public TSType setExport(boolean exports) {
super.put(EXPORT, exports);
public TSType setExport(boolean value) {
super.put(EXPORT, value);
return this;
}

Expand All @@ -95,6 +97,34 @@ public String getAlias() {
return (String) super.get(ALIAS);
}

/**
*
* @return
*/
public boolean isFunctionalInterface() {


if( !getValue().isInterface()) return false;
if( getValue().isAnnotationPresent(FunctionalInterface.class)) return true;

//return Arrays.stream(c.getDeclaredMethods())
// .filter( m -> Modifier.isAbstract(m.getModifiers()) )
// .count() == 1;

return (Boolean)super.getOrDefault( FUNCTIONAL, false);
}

/**
*
*/
public TSType setFunctionalInterface( boolean value ) {

super.put(FUNCTIONAL, value);
return this;

}


private String getMemberSimpleTypeName() {

return format( "%s$%s", getValue().getDeclaringClass().getSimpleName(), getValue().getSimpleName());
Expand Down Expand Up @@ -134,13 +164,6 @@ public final String getNamespace() {
return (String) super.getOrDefault(NAMESPACE, getValue().getPackage().getName());
}

/**
*
* @return
*/
public boolean isFunctionalInterface() {
return TypescriptConverter.isFunctionalInterface( getValue() );
}
/**
*
* @param type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@Target( {ElementType.ANNOTATION_TYPE} )
public @interface Type {
Class<?> value();
boolean export() default false ;
String alias() default "";
boolean export() default false ;
String alias() default "";
boolean functional() default false;
}

0 comments on commit e69e29e

Please sign in to comment.