Skip to content

Commit

Permalink
Fix getter prefix for boolean and make stringEndingWith write actually
Browse files Browse the repository at this point in the history
work.
  • Loading branch information
cjritola committed Apr 10, 2024
1 parent fbe2e6d commit 52b1cfb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/org/jtrfp/jfdt/Parser.java
Expand Up @@ -233,7 +233,10 @@ private static void setInt(ThirdPartyParseable obj, String property, Integer val
private <CLASS> CLASS get(ThirdPartyParseable obj, String property, Class <? extends CLASS> propertyReturnClass){
try {
final Class<?>[] nullClasses = null;
Method method = obj.getClass().getMethod("get"+Character.toUpperCase(property.charAt(0))+property.substring(1), nullClasses);
String prefix = "get";
if(propertyReturnClass == boolean.class || propertyReturnClass == Boolean.class)
prefix = "is";
Method method = obj.getClass().getMethod(prefix+Character.toUpperCase(property.charAt(0))+property.substring(1), nullClasses);
if(propertyReturnClass==String.class){
Object result = method.invoke(obj, (Object[])null);
if(!result.getClass().isEnum())return (CLASS)new String(""+result);
Expand Down Expand Up @@ -924,7 +927,10 @@ public void read(EndianAwareDataInputStream is,
@Override
public void write(EndianAwareDataOutputStream os,
ThirdPartyParseable bean) throws IOException{
os.write(sParser.parseWrite(bean).getBytes());
//Read the property value from the bean
CLASS val = property.get(bean);
final String valString = sParser.parseWrite(val);
os.write(valString.getBytes());
//os.write(property.getAsString(bean).getBytes());
if(ending!=null)os.write(ending.getBytes());
}
Expand Down

0 comments on commit 52b1cfb

Please sign in to comment.