Tabnine Logo
Class.toString
Code IndexAdd Tabnine to your IDE (free)

How to use
toString
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.toString (Showing top 20 results out of 15,264)

origin: spring-projects/spring-framework

private boolean matchesClassCastMessage(String classCastMessage, Class<?> eventClass) {
  // On Java 8, the message starts with the class name: "java.lang.String cannot be cast..."
  if (classCastMessage.startsWith(eventClass.getName())) {
    return true;
  }
  // On Java 11, the message starts with "class ..." a.k.a. Class.toString()
  if (classCastMessage.startsWith(eventClass.toString())) {
    return true;
  }
  // On Java 9, the message used to contain the module name: "java.base/java.lang.String cannot be cast..."
  int moduleSeparatorIndex = classCastMessage.indexOf('/');
  if (moduleSeparatorIndex != -1 && classCastMessage.startsWith(eventClass.getName(), moduleSeparatorIndex + 1)) {
    return true;
  }
  // Assuming an unrelated class cast failure...
  return false;
}
origin: bumptech/glide

@SuppressWarnings("PMD.PreserveStackTrace")
private static void appendExceptionMessage(Throwable t, Appendable appendable) {
 try {
  appendable.append(t.getClass().toString()).append(": ").append(t.getMessage()).append('\n');
 } catch (IOException e1) {
  throw new RuntimeException(t);
 }
}
origin: neo4j/neo4j

private Map<String, Map<String, String>> map( Class<? extends PropertyContainer> cls )
{
  if ( cls.equals( Node.class ) )
  {
    return nodeConfig;
  }
  else if ( cls.equals( Relationship.class ) )
  {
    return relConfig;
  }
  throw new IllegalArgumentException( cls.toString() );
}
origin: apache/flink

private String fieldTypesToString() {
  StringBuilder string = new StringBuilder();
  string.append(this.fieldTypes[0].toString());
  for (int i = 1; i < this.fieldTypes.length; i++) {
    string.append(", ").append(this.fieldTypes[i]);
  }
  
  return string.toString();
}
origin: org.testng/testng

/**
 * @return A hashcode representing the name of this method and its parameters,
 * but without its class
 */
private static String createMethodKey(Method m) {
 StringBuilder result = new StringBuilder(m.getName());
 for (Class paramClass : m.getParameterTypes()) {
  result.append(' ').append(paramClass.toString());
 }
 return result.toString();
}
 
origin: hankcs/HanLP

private static Object createValue(Class<?> type, String valueAsString) throws NoSuchMethodException
{
  for (ValueCreator valueCreator : valueCreators)
  {
    Object createdValue = valueCreator.createValue(type, valueAsString);
    if (createdValue != null)
    {
      return createdValue;
    }
  }
  throw new IllegalArgumentException(String.format("cannot instanciate any %s object using %s value", type.toString(), valueAsString));
}
origin: redisson/redisson

/**
 * {@inheritDoc}
 */
public Annotation resolve() {
  throw new IncompatibleClassChangeError("Not an annotation type: " + incompatibleType.toString());
}
origin: redisson/redisson

/**
 * {@inheritDoc}
 */
public Enum<?> resolve() {
  throw new IncompatibleClassChangeError("Not an enumeration type: " + type.toString());
}
origin: org.mockito/mockito-core

public static MockitoException cannotMockClass(Class<?> clazz, String reason) {
  return new MockitoException(join(
      "Cannot mock/spy " + clazz.toString(),
      "Mockito cannot mock/spy because :",
      " - " + reason
  ));
}
origin: prestodb/presto

@Override
public final T getNullValue(DeserializationContext ctxt) throws JsonMappingException {
  // 01-Mar-2017, tatu: Alas, not all paths lead to `_coerceNull()`, as `SettableBeanProperty`
  //    short-circuits `null` handling. Hence need this check as well.
  if (_primitive && ctxt.isEnabled(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)) {
    ctxt.reportInputMismatch(this,
        "Cannot map `null` into type %s (set DeserializationConfig.DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES to 'false' to allow)",
        handledType().toString());
  }
  return _nullValue;
}
origin: redisson/redisson

@Override
public final T getNullValue(DeserializationContext ctxt) throws JsonMappingException {
  // 01-Mar-2017, tatu: Alas, not all paths lead to `_coerceNull()`, as `SettableBeanProperty`
  //    short-circuits `null` handling. Hence need this check as well.
  if (_primitive && ctxt.isEnabled(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)) {
    ctxt.reportInputMismatch(this,
        "Cannot map `null` into type %s (set DeserializationConfig.DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES to 'false' to allow)",
        handledType().toString());
  }
  return _nullValue;
}
origin: ReactiveX/RxJava

@Test
public void just() {
  Flowable<Integer> source = Flowable.fromArray(new Integer[] { 1 });
  Assert.assertTrue(source.getClass().toString(), source instanceof ScalarCallable);
}
origin: ReactiveX/RxJava

  @SuppressWarnings("unchecked")
  @Test
  public void scalarCallable() {
    Maybe<Integer> m = Maybe.just(1);

    assertTrue(m.getClass().toString(), m instanceof ScalarCallable);

    assertEquals(1, ((ScalarCallable<Integer>)m).call().intValue());
  }
}
origin: ReactiveX/RxJava

@SuppressWarnings("unchecked")
@Test
public void callable() throws Exception {
  final int[] counter = { 0 };
  Maybe<Void> m = Maybe.fromAction(new Action() {
    @Override
    public void run() throws Exception {
      counter[0]++;
    }
  });
  assertTrue(m.getClass().toString(), m instanceof Callable);
  assertNull(((Callable<Void>)m).call());
  assertEquals(1, counter[0]);
}
origin: ReactiveX/RxJava

@SuppressWarnings("unchecked")
@Test
public void callable() throws Exception {
  final int[] counter = { 0 };
  Maybe<Void> m = Maybe.fromRunnable(new Runnable() {
    @Override
    public void run() {
      counter[0]++;
    }
  });
  assertTrue(m.getClass().toString(), m instanceof Callable);
  assertNull(((Callable<Void>)m).call());
  assertEquals(1, counter[0]);
}
origin: ReactiveX/RxJava

@SuppressWarnings("unchecked")
@Test
public void callable() throws Exception {
  final int[] counter = { 0 };
  Maybe<Integer> m = Maybe.fromCallable(new Callable<Integer>() {
    @Override
    public Integer call() throws Exception {
      counter[0]++;
      return 0;
    }
  });
  assertTrue(m.getClass().toString(), m instanceof Callable);
  assertEquals(0, ((Callable<Void>)m).call());
  assertEquals(1, counter[0]);
}
origin: ReactiveX/RxJava

  @Test
  public void scalarCallable() {
    Maybe<Integer> m = Maybe.empty();

    assertTrue(m.getClass().toString(), m instanceof ScalarCallable);

    assertNull(((ScalarCallable<?>)m).call());
  }
}
origin: ReactiveX/RxJava

@Test
public void source() {
  Maybe<Integer> m = Maybe.just(1);
  Single<Integer> s = m.toSingle();
  assertTrue(s.getClass().toString(), s instanceof HasUpstreamMaybeSource);
  assertSame(m, (((HasUpstreamMaybeSource<?>)s).source()));
}
origin: spring-projects/spring-framework

@Test
public void processHeadersToSend() {
  Map<String, Object> map = this.messagingTemplate.processHeadersToSend(null);
  assertNotNull(map);
  assertTrue("Actual: " + map.getClass().toString(), MessageHeaders.class.isAssignableFrom(map.getClass()));
  SimpMessageHeaderAccessor headerAccessor =
      MessageHeaderAccessor.getAccessor((MessageHeaders) map, SimpMessageHeaderAccessor.class);
  assertTrue(headerAccessor.isMutable());
  assertEquals(SimpMessageType.MESSAGE, headerAccessor.getMessageType());
}
origin: spring-projects/spring-framework

@Test
public void setPropertyWithCustomEditor() {
  MutablePropertyValues values = new MutablePropertyValues();
  values.add("name", Integer.class);
  TestBean target = new TestBean();
  AbstractPropertyAccessor accessor = createAccessor(target);
  accessor.registerCustomEditor(String.class, new PropertyEditorSupport() {
    @Override
    public void setValue(Object value) {
      super.setValue(value.toString());
    }
  });
  accessor.setPropertyValues(values);
  assertEquals(Integer.class.toString(), target.getName());
}
java.langClasstoString

Javadoc

Converts the object to a string. The string representation is the string "class" or "interface", followed by a space, and then by the fully qualified name of the class in the format returned by getName. If this Class object represents a primitive type, this method returns the name of the primitive type. If this Class object represents void this method returns "void".

Popular methods of Class

  • getName
    Returns the name of the class represented by this Class. For a description of the format which is us
  • getSimpleName
  • getClassLoader
  • isAssignableFrom
    Determines if the class or interface represented by this Class object is either the same as, or is a
  • forName
    Returns the Class object associated with the class or interface with the given string name, using th
  • newInstance
    Returns a new instance of the class represented by this Class, created by invoking the default (that
  • getMethod
    Returns a Method object that reflects the specified public member method of the class or interface r
  • getResourceAsStream
  • getSuperclass
    Returns the Class representing the superclass of the entity (class, interface, primitive type or voi
  • getConstructor
  • cast
    Casts an object to the class or interface represented by this Class object.
  • isInstance
  • cast,
  • isInstance,
  • getCanonicalName,
  • getDeclaredField,
  • isArray,
  • getAnnotation,
  • getDeclaredFields,
  • getResource,
  • getDeclaredMethod,
  • getMethods

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • JFileChooser (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now