forked from ironchefpython/modapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored most properties into DynamicValueProperty
- Loading branch information
ironchefpython
committed
May 3, 2012
1 parent
362a665
commit ae0d966
Showing
16 changed files
with
167 additions
and
445 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
55 changes: 0 additions & 55 deletions
55
src/org/ironchefpython/modapi/AbstractDynamicProperty.java
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.ironchefpython.modapi; | ||
|
||
import org.ironchefpython.modapi.error.PropertyError; | ||
|
||
public class DynamicValueProperty implements DynamicProperty { | ||
private Class<?> type; | ||
private Object value; | ||
|
||
public DynamicValueProperty(Class<?> type, Object value) { | ||
this.type = type; | ||
this.value = value; | ||
} | ||
|
||
public boolean isStatic() { | ||
return false; | ||
} | ||
|
||
public Object getValue() { | ||
return value; | ||
} | ||
|
||
public DynamicProperty cloneWith(Object object) throws PropertyError { | ||
if (object == null) { | ||
return this; | ||
} | ||
throw PropertyError.IllegalAccessException(this.getClass().getName()); | ||
} | ||
|
||
public Class<?> getJavaType() { | ||
return type; | ||
} | ||
|
||
public Class<?> getFieldType() { | ||
return type; | ||
} | ||
|
||
protected static DynamicProperty makeType(final Class<?> type) { | ||
return new DynamicTypeProperty() { | ||
public DynamicProperty cloneWith(Object object) { | ||
try { | ||
return (object == null ? this : new DynamicValueProperty(type, object)); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public Class<?> getJavaType() { | ||
return type; | ||
} | ||
}; | ||
} | ||
|
||
abstract static class DynamicTypeProperty implements DynamicProperty { | ||
public boolean isStatic() { | ||
return false; | ||
} | ||
|
||
public Object getValue() { | ||
// FIXME produce a better result for a null value | ||
throw new NoSuchMethodError(); | ||
} | ||
|
||
public abstract Class<?> getJavaType(); | ||
|
||
public Class<?> getFieldType() { | ||
return getJavaType(); | ||
} | ||
|
||
} | ||
|
||
} |
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
Oops, something went wrong.