-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
699074d
commit 86ea8fe
Showing
12 changed files
with
173 additions
and
31 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
78 changes: 78 additions & 0 deletions
78
src/main/java/com/github/highcharts4gwt/generator/option/field/FieldSeriesWriter.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.github.highcharts4gwt.generator.option.field; | ||
|
||
import javax.annotation.CheckForNull; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.github.highcharts4gwt.generator.common.ClassRegistry; | ||
import com.github.highcharts4gwt.generator.common.OutputType; | ||
import com.github.highcharts4gwt.generator.common.OutputTypeVisitor; | ||
import com.github.highcharts4gwt.generator.option.Option; | ||
import com.github.highcharts4gwt.model.array.api.Array; | ||
import com.sun.codemodel.JClass; | ||
import com.sun.codemodel.JCodeModel; | ||
import com.sun.codemodel.JDefinedClass; | ||
|
||
public class FieldSeriesWriter extends AbstractFieldWriter implements OutputTypeVisitor<Void, Void> | ||
{ | ||
private static final Logger logger = LoggerFactory.getLogger(FieldSeriesWriter.class); | ||
|
||
private final String defaultValue; | ||
private final Option option; | ||
|
||
public FieldSeriesWriter(JDefinedClass jClass, Option option, boolean pipe, String fieldName) | ||
{ | ||
super(jClass, pipe, fieldName, option.getDescription()); | ||
this.option = option; | ||
this.defaultValue = option.getDefaults(); | ||
} | ||
|
||
@Override | ||
@CheckForNull | ||
public Void visitInterface(Void in) | ||
{ | ||
JClass fieldClazz = getNarrowedArrayClass(); | ||
if (fieldClazz == null) | ||
return null; | ||
|
||
InterfaceFieldHelper.addGetterSetterDeclaration(getNames(), fieldClazz, getJclass()); | ||
return null; | ||
} | ||
|
||
@Override | ||
@CheckForNull | ||
public Void visitJso(Void in) | ||
{ | ||
return null; | ||
} | ||
|
||
@Override | ||
@CheckForNull | ||
public Void visitMock(Void in) | ||
{ | ||
return null; | ||
} | ||
|
||
private JClass getNarrowedArrayClass() | ||
{ | ||
// use interface type | ||
JClass jClass = ClassRegistry.INSTANCE.getRegistry().get(new ClassRegistry.RegistryKey(option, OutputType.Interface)); | ||
|
||
if (jClass == null) | ||
{ | ||
logger.error("Could not create Array<Object> for type " + option.getFullname()); | ||
return null; | ||
} | ||
|
||
JClass genericArray = new JCodeModel().ref(Array.class); | ||
JClass arrayOfSpecializedType = genericArray.narrow(jClass); | ||
return arrayOfSpecializedType; | ||
} | ||
|
||
@Override | ||
protected String getNameExtension() | ||
{ | ||
return "AsArrayObject"; | ||
} | ||
} |
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
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
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
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