code: public <T extends Facet> T getFacet(Class<T> type) {
          for (Facet f : facets)
              if(type==f.getClass())
                  return type.cast(f);
          return null;
      }
docs: If the facet of the given type exists, return it. Otherwise null.