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

How to use
isAnonymousClass
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.isAnonymousClass (Showing top 20 results out of 3,033)

origin: redisson/redisson

/**
 * {@inheritDoc}
 */
public boolean isAnonymousType() {
  return type.isAnonymousClass();
}
origin: spring-projects/spring-loaded

public static boolean callIsAnonymousClass(Class thiz)
{
  return thiz.isAnonymousClass();
}
origin: redisson/redisson

  public static Class getRealEnumClass(Class enumClass) {
    if (enumClass.isAnonymousClass()) {
      return enumClass.getSuperclass();
    }
    return enumClass;
  }
}
origin: redisson/redisson

protected void check(Object task) {
  if (task == null) {
    throw new NullPointerException("Task is not defined");
  }
  if (task.getClass().isAnonymousClass()) {
    throw new IllegalArgumentException("Task can't be created using anonymous class");
  }
  if (task.getClass().isMemberClass()
      && !Modifier.isStatic(task.getClass().getModifiers())) {
    throw new IllegalArgumentException("Task class is an inner class and it should be static");
  }
}

origin: redisson/redisson

private void check(Object task) {
  if (task == null) {
    throw new NullPointerException("Task is not defined");
  }
  if (task.getClass().isAnonymousClass()) {
    throw new IllegalArgumentException("Task can't be created using anonymous class");
  }
  if (task.getClass().isMemberClass()
      && !Modifier.isStatic(task.getClass().getModifiers())) {
    throw new IllegalArgumentException("Task class is an inner class and it should be static");
  }
}
origin: redisson/redisson

private void check(Object task) {
  if (task == null) {
    throw new NullPointerException("Task is not defined");
  }
  if (task.getClass().isAnonymousClass()) {
    throw new IllegalArgumentException("Task can't be created using anonymous class");
  }
  if (task.getClass().isMemberClass()
      && !Modifier.isStatic(task.getClass().getModifiers())) {
    throw new IllegalArgumentException("Task class is an inner class and it should be static");
  }
}
origin: redisson/redisson

protected void check(Object task) {
  if (task == null) {
    throw new NullPointerException("Task is not defined");
  }
  if (task.getClass().isAnonymousClass()) {
    throw new IllegalArgumentException("Task can't be created using anonymous class");
  }
  if (task.getClass().isMemberClass()
      && !Modifier.isStatic(task.getClass().getModifiers())) {
    throw new IllegalArgumentException("Task class is an inner class and it should be static");
  }
}

origin: apache/flink

private static boolean isAnonymousClass(Class clazz) {
  final String name = clazz.getName();
  // isAnonymousClass does not work for anonymous Scala classes; additionally check by class name
  if (name.contains("$anon$") || name.contains("$anonfun") || name.contains("$macro$")) {
    return true;
  }
  // calling isAnonymousClass or getSimpleName can throw InternalError for certain Scala types, see https://issues.scala-lang.org/browse/SI-2034
  // until we move to JDK 9, this try-catch is necessary
  try {
    return clazz.isAnonymousClass();
  } catch (InternalError e) {
    return false;
  }
}
origin: eclipse-vertx/vert.x

/**
 * @deprecated see https://github.com/eclipse-vertx/vert.x/issues/2774
 */
@Deprecated
public static Logger getLogger(final Class<?> clazz) {
 String name = clazz.isAnonymousClass() ?
  clazz.getEnclosingClass().getCanonicalName() :
  clazz.getCanonicalName();
 return getLogger(name);
}
origin: prestodb/presto

public void register(PlanOptimizer optimizer)
{
  requireNonNull(optimizer, "optimizer is null");
  checkArgument(!optimizer.getClass().isAnonymousClass());
  stats.put(optimizer.getClass(), new OptimizerStats());
}
origin: prestodb/presto

public void registerAll(Collection<Rule<?>> rules)
{
  for (Rule<?> rule : rules) {
    checkArgument(!rule.getClass().isAnonymousClass());
    stats.put(rule.getClass(), new RuleStats());
  }
}
origin: org.assertj/assertj-core

@Override
public String unambiguousToStringOf(Object obj) {
 return obj == null ? null
   : String.format("%s (%s@%s)",
           toStringOf(obj),
           obj.getClass().isAnonymousClass() ? obj.getClass().getName() : obj.getClass().getSimpleName(),
           toHexString(System.identityHashCode(obj)));
}
origin: nutzam/nutz

public boolean checkClass(Class<?> klass) {
  return !(klass.isInterface()
       || klass.isArray()
       || klass.isEnum()
       || klass.isPrimitive()
       || klass.isMemberClass()
       || klass.isAnnotation()
       || klass.isAnonymousClass());
}
origin: redisson/redisson

/**
 * get cross platform symbolic class identifier
 * @param cl
 * @return
 */
public String getCPNameForClass( Class cl ) {
  String res = minbinNamesReverse.get(cl.getName());
  if (res == null) {
    if (cl.isAnonymousClass()) {
      return getCPNameForClass(cl.getSuperclass());
    }
    return cl.getName();
  }
  return res;
}
origin: JakeWharton/hugo

 private static String asTag(Class<?> cls) {
  if (cls.isAnonymousClass()) {
   return asTag(cls.getEnclosingClass());
  }
  return cls.getSimpleName();
 }
}
origin: apache/flink

private static String generateFunctionName(Function function) {
  Class<? extends Function> functionClass = function.getClass();
  if (functionClass.isAnonymousClass()) {
    // getSimpleName returns an empty String for anonymous classes
    Type[] interfaces = functionClass.getInterfaces();
    if (interfaces.length == 0) {
      // extends an existing class (like RichMapFunction)
      Class<?> functionSuperClass = functionClass.getSuperclass();
      return functionSuperClass.getSimpleName() + functionClass.getName().substring(functionClass.getEnclosingClass().getName().length());
    } else {
      // implements a Function interface
      Class<?> functionInterface = functionClass.getInterfaces()[0];
      return functionInterface.getSimpleName() + functionClass.getName().substring(functionClass.getEnclosingClass().getName().length());
    }
  } else {
    return functionClass.getSimpleName();
  }
}
origin: square/javapoet

public static ClassName get(Class<?> clazz) {
 checkNotNull(clazz, "clazz == null");
 checkArgument(!clazz.isPrimitive(), "primitive types cannot be represented as a ClassName");
 checkArgument(!void.class.equals(clazz), "'void' type cannot be represented as a ClassName");
 checkArgument(!clazz.isArray(), "array types cannot be represented as a ClassName");
 String anonymousSuffix = "";
 while (clazz.isAnonymousClass()) {
  int lastDollar = clazz.getName().lastIndexOf('$');
  anonymousSuffix = clazz.getName().substring(lastDollar) + anonymousSuffix;
  clazz = clazz.getEnclosingClass();
 }
 String name = clazz.getSimpleName() + anonymousSuffix;
 if (clazz.getEnclosingClass() == null) {
  // Avoid unreliable Class.getPackage(). https://github.com/square/javapoet/issues/295
  int lastDot = clazz.getName().lastIndexOf('.');
  String packageName = (lastDot != -1) ? clazz.getName().substring(0, lastDot) : null;
  return new ClassName(packageName, null, name);
 }
 return ClassName.get(clazz.getEnclosingClass()).nestedClass(name);
}
origin: querydsl/querydsl

  @Override
  public boolean apply(Class<?> input) {
    return !input.isAnonymousClass()
        && !input.isMemberClass();
  }
};
origin: apache/kylin

private String getAggregatorName(Class<? extends MeasureAggregator> clazz) {
  if (!clazz.isAnonymousClass()) {
    return clazz.getSimpleName();
  }
  String[] parts = clazz.getName().split("\\.");
  return parts[parts.length - 1];
}
origin: apache/flink

  private static void validataSerialVersionUID(Class<?> clazz) {
    // all non-interface types must have a serial version UID
    if (!clazz.isInterface()) {
      assertFalse("Anonymous state handle classes have problematic serialization behavior: " + clazz,
          clazz.isAnonymousClass());

      try {
        Field versionUidField = clazz.getDeclaredField("serialVersionUID");

        // check conditions first via "if" to prevent always constructing expensive error messages
        if (!(Modifier.isPrivate(versionUidField.getModifiers()) &&
            Modifier.isStatic(versionUidField.getModifiers()) &&
            Modifier.isFinal(versionUidField.getModifiers()))) {
          fail(clazz.getName() + " - serialVersionUID is not 'private static final'");
        }
      }
      catch (NoSuchFieldException e) {
        fail("State handle implementation '" + clazz.getName() + "' is missing the serialVersionUID");
      }
    }
  }
}
java.langClassisAnonymousClass

Javadoc

Tests whether the class represented by this Class is anonymous.

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
    Finds a resource with a given name. The rules for searching resources associated with a given class
  • 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
  • Github Copilot alternatives
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