Chris Nokleberg
Chris Nokleberg
Attributes.get(Key key) current has @SuppressWarnings("unchecked"). It is actually not safe--Key.of will return a key for any and it is never enforced. (It is generally a bad practice for a method...
For example: Key ikey = Key.of("mykey"); Key skey = (Key) ikey; Attributes attr = Attributes.newBuilder() .set(skey, "foo") .build(); System.err.println("result: " + attr.get(ikey)); Prints "result: foo", even though get here is...
List is a good example, because Collections.checkedList does exist, for reasons that also apply here: http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#checkedCollection(java.util.Collection,%20java.lang.Class)
I doubt there are good use cases for generic values here. But I've also realized that I'm just repeating the advice already in Effective Java 2nd ed. Item 29, so...
Yes there is no good solution if you want to support generic values--they have a bunch of problems. But as I mentioned, I doubt there is a real use case...
Could we just generate full orbit tables, which would allow us to avoid using the JDK upper/lower methods altogether? I would be surprised if there was a significant performance impact....