> On June 27, 2014, 11:37 p.m., Kevin Sweeney wrote:
> > src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/AbstractTEnumTypeHandler.java,
> >  line 31
> > <https://reviews.apache.org/r/23105/diff/1/?file=619253#file619253line31>
> >
> >     You could write this without an abstract class and make a static 
> > factory method that takes a Class<T> here and uses reflection here. This 
> > would seem to reduce boilerplate.
> >     
> >     For example:
> >     
> >     TypeHandler<T extends TEnum> forThriftEnum(Class<T> enumType) {
> >       final Method fromValue = enumType.getMethod("fromValue", int.class);
> >       return new AbstractTEnumTypeHandler<T>() {
> >         ...    
> >         T fromValue(int value) {
> >           return (T) fromValue.invoke(klazz, value);
> >         }
> >       }
> >     }

This would work if you could provide instances of TypeHandler, but you need to 
provide Classes.  The snippet above would leave you with no Class name to 
reference in AttributeMapper.xml.  Working the opposite direction, i don't 
think there's a way to write one type handler that can infer the target enum 
type on the fly.


- Bill


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/23105/#review46925
-----------------------------------------------------------


On June 27, 2014, 3:39 p.m., Bill Farner wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/23105/
> -----------------------------------------------------------
> 
> (Updated June 27, 2014, 3:39 p.m.)
> 
> 
> Review request for Aurora, Kevin Sweeney and Maxim Khutornenko.
> 
> 
> Bugs: AURORA-557
>     https://issues.apache.org/jira/browse/AURORA-557
> 
> 
> Repository: aurora
> 
> 
> Description
> -------
> 
> There are a few different characteristics of this mapper compared to others 
> so far:
> - custom type handler (see AbstractTEnumTypeHandler and 
> MaintenanceModeTypeHandler)
> - outer join (to allow a HostAttributes with an empty Attributes set)
> - batch insert via foreach
> - collection, and nested collection result mapping
> 
> You may find this page helpful to explain the features used: 
> http://mybatis.github.io/mybatis-3/sqlmap-xml.html#Result_Maps
> 
> 
> Diffs
> -----
> 
>   src/main/java/org/apache/aurora/scheduler/storage/db/AttributeMapper.java 
> PRE-CREATION 
>   src/main/java/org/apache/aurora/scheduler/storage/db/DbAttributeStore.java 
> PRE-CREATION 
>   src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java 
> 1738b95cd67cf990bd8aad8c744a1febe2d87f15 
>   src/main/java/org/apache/aurora/scheduler/storage/db/DbStorage.java 
> c683e398640c7ebf2047ef308a701cb4897c58dc 
>   src/main/java/org/apache/aurora/scheduler/storage/db/EnumValueMapper.java 
> PRE-CREATION 
>   src/main/java/org/apache/aurora/scheduler/storage/db/MigrationModule.java 
> 505c94d6800c1453b1b1f696ef774f5943973f19 
>   
> src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/AbstractTEnumTypeHandler.java
>  PRE-CREATION 
>   
> src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/MaintenanceModeTypeHandler.java
>  PRE-CREATION 
>   
> src/main/java/org/apache/aurora/scheduler/storage/db/typehandlers/TypeHandlers.java
>  PRE-CREATION 
>   
> src/main/java/org/apache/aurora/scheduler/storage/mem/MemAttributeStore.java 
> 4bb807c04e47a091c83a575850ebfc3b244bfa73 
>   src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorage.java 
> 65750b61b864f0e830513039a7c9d727ac9d493d 
>   src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorageModule.java 
> 23555c2483d7fe716243847f8478898e98fb5ac4 
>   
> src/main/resources/org/apache/aurora/scheduler/storage/db/AttributeMapper.xml 
> PRE-CREATION 
>   
> src/main/resources/org/apache/aurora/scheduler/storage/db/EnumValueMapper.xml 
> PRE-CREATION 
>   src/main/resources/org/apache/aurora/scheduler/storage/db/LockMapper.xml 
> 31b98cb3107a88756694922de01fa0ba267f3e9d 
>   src/main/resources/org/apache/aurora/scheduler/storage/db/schema.sql 
> 3298eb38644b6fa7096801a69f8b88d0331ce4a7 
>   
> src/test/java/org/apache/aurora/scheduler/storage/db/DbAttributeStoreTest.java
>  PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/23105/diff/
> 
> 
> Testing
> -------
> 
> ./gradlew run -Pq
> 
> 
> Thanks,
> 
> Bill Farner
> 
>

Reply via email to