@Test public void testAs$notSupported() throws Exception { try { term().as(Double.class); fail("Should not cast to Double"); } catch (UnsupportedOperationException e) { assertThat(e.getCause(),instanceOf(CannotAdaptClassesException.class)); } }
@Override public <V> V as(Class<? extends V> valueClass) { try { return TypeAdapter.adapt(this, valueClass); } catch (CannotAdaptClassesException e) { throw new UnsupportedOperationException("Class '"+getClass().getCanonicalName()+" cannot be transformed to '"+valueClass.getCanonicalName()+"'",e); } }
ImmutableTerm implements Term { @Override public <V> V as(Class<? extends V> valueClass) { try { return TypeAdapter.adapt(this, valueClass); } catch (CannotAdaptClassesException e) { throw new UnsupportedOperationException("Class '"+getClass().getCanonicalName()+" cannot be transformed to '"+valueClass.getCanonicalName()+"'",e); } } }
ImmutableTerm implements Term { @Override public <V> V as(Class<? extends V> valueClass) { try { return TypeAdapter.adapt(this, valueClass); } catch (CannotAdaptClassesException e) { throw new UnsupportedOperationException("Class '"+getClass().getCanonicalName()+" cannot be transformed to '"+valueClass.getCanonicalName()+"'",e); } } ImmutableTerm(AbstractImmutableVocabulary<? extends ImmutableTerm> vocabulary, String entityName); }
ImmutableTerm implements Term { @Override public <V> V as(Class<? extends V> valueClass) { try { return TypeAdapter.adapt(this, valueClass); } catch (CannotAdaptClassesException e) { throw new UnsupportedOperationException("Class '"+getClass().getCanonicalName()+" cannot be transformed to '"+valueClass.getCanonicalName()+"'",e); } } ImmutableTerm(AbstractImmutableVocabulary<? extends ImmutableTerm> vocabulary, String entityName); @Override final int ordinal(); @Override final String name(); @Override final String entityName(); @Override final String qualifiedEntityName(); @Override final Vocabulary getDeclaringVocabulary(); @Override V as(Class<? extends V> valueClass); @Override final boolean equals(Object other); @Override final int hashCode(); @Override String toString(); @Override int compareTo(Term other); }
ImmutableTerm implements Term { @Override public <V> V as(Class<? extends V> valueClass) { try { return TypeAdapter.adapt(this, valueClass); } catch (CannotAdaptClassesException e) { throw new UnsupportedOperationException("Class '"+getClass().getCanonicalName()+" cannot be transformed to '"+valueClass.getCanonicalName()+"'",e); } } ImmutableTerm(AbstractImmutableVocabulary<? extends ImmutableTerm> vocabulary, String entityName); @Override final int ordinal(); @Override final String name(); @Override final String entityName(); @Override final String qualifiedEntityName(); @Override final Vocabulary getDeclaringVocabulary(); @Override V as(Class<? extends V> valueClass); @Override final boolean equals(Object other); @Override final int hashCode(); @Override String toString(); @Override int compareTo(Term other);  }