com.squareup.javapoet.ClassName.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中com.squareup.javapoet.ClassName.<init>()方法的一些代码示例,展示了ClassName.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassName.<init>()方法的具体详情如下:
包路径:com.squareup.javapoet.ClassName
类名称:ClassName
方法名:<init>

ClassName.<init>介绍

暂无

代码示例

代码示例来源:origin: square/javapoet

/**
 * Returns a class that shares the same enclosing package or class. If this class is enclosed by
 * another class, this is equivalent to {@code enclosingClassName().nestedClass(name)}. Otherwise
 * it is equivalent to {@code get(packageName(), name)}.
 */
public ClassName peerClass(String name) {
 return new ClassName(packageName, enclosingClassName, name);
}

代码示例来源:origin: square/javapoet

/**
 * Returns a new {@link ClassName} instance for the specified {@code name} as nested inside this
 * class.
 */
public ClassName nestedClass(String name) {
 return new ClassName(packageName, this, name);
}

代码示例来源:origin: stackoverflow.com

// send where details is object
ClassName details = new ClassName();
Intent i = new Intent(context, EditActivity.class);
i.putExtra("Editing", details);
startActivity(i);

//receive
ClassName model = (ClassName) getIntent().getSerializableExtra("Editing");

And 

Class ClassName implements Serializable {
}

代码示例来源:origin: square/javapoet

@Override public ClassName visitPackage(PackageElement packageElement, Void p) {
 return new ClassName(packageElement.getQualifiedName().toString(), null, simpleName);
}

代码示例来源:origin: square/javapoet

@Override public ClassName annotated(List<AnnotationSpec> annotations) {
 return new ClassName(packageName, enclosingClassName, simpleName,
   concatAnnotations(annotations));
}

代码示例来源:origin: square/javapoet

/**
 * Returns a class name created from the given parts. For example, calling this with package name
 * {@code "java.util"} and simple names {@code "Map"}, {@code "Entry"} yields {@link Map.Entry}.
 */
public static ClassName get(String packageName, String simpleName, String... simpleNames) {
 ClassName className = new ClassName(packageName, null, simpleName);
 for (String name : simpleNames) {
  className = className.nestedClass(name);
 }
 return className;
}

代码示例来源:origin: square/javapoet

/**
 * Returns a new {@link ClassName} instance for the given fully-qualified class name string. This
 * method assumes that the input is ASCII and follows typical Java style (lowercase package
 * names, UpperCamelCase class names) and may produce incorrect results or throw
 * {@link IllegalArgumentException} otherwise. For that reason, {@link #get(Class)} and
 * {@link #get(Class)} should be preferred as they can correctly create {@link ClassName}
 * instances without such restrictions.
 */
public static ClassName bestGuess(String classNameString) {
 // Add the package name, like "java.util.concurrent", or "" for no package.
 int p = 0;
 while (p < classNameString.length() && Character.isLowerCase(classNameString.codePointAt(p))) {
  p = classNameString.indexOf('.', p) + 1;
  checkArgument(p != 0, "couldn't make a guess for %s", classNameString);
 }
 String packageName = p == 0 ? "" : classNameString.substring(0, p - 1);
 // Add class names like "Map" and "Entry".
 ClassName className = null;
 for (String simpleName : classNameString.substring(p).split("\\.", -1)) {
  checkArgument(!simpleName.isEmpty() && Character.isUpperCase(simpleName.codePointAt(0)),
    "couldn't make a guess for %s", classNameString);
  className = new ClassName(packageName, className, simpleName);
 }
 return className;
}

代码示例来源:origin: square/javapoet

@Override public ClassName withoutAnnotations() {
 if (!isAnnotated()) return this;
 ClassName resultEnclosingClassName = enclosingClassName != null
   ? enclosingClassName.withoutAnnotations()
   : null;
 return new ClassName(packageName, resultEnclosingClassName, simpleName);
}

代码示例来源: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: stackoverflow.com

function ClassName(){

}

ClassName.prototype = { //Put instance methods here
  instanceMethod1 : function(){},

  instanceMethod2 : function(){}
};

ClassName.staticMethod1 = function(){};
ClassName.staticMethod2 = function(){};

var a = new ClassName();

a.staticMethod1; //undefined
a.instanceMethod1; //function(){};

ClassName.staticMethod1 //function(){};

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Returns the top class in this nesting group. Equivalent to chained calls to {@link
 * #enclosingClassName()} until the result's enclosing class is null.
 */
public ClassName topLevelClassName() {
 return new ClassName(names.subList(0, 2));
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Returns a class that shares the same enclosing package or class. If this class is enclosed by
 * another class, this is equivalent to {@code enclosingClassName().nestedClass(name)}. Otherwise
 * it is equivalent to {@code get(packageName(), name)}.
 */
public ClassName peerClass(String name) {
 List<String> result = new ArrayList<>(names);
 result.set(result.size() - 1, name);
 return new ClassName(result);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Returns a class name created from the given parts. For example, calling this with package name
 * {@code "java.util"} and simple names {@code "Map"}, {@code "Entry"} yields {@link Map.Entry}.
 */
public static ClassName get(String packageName, String simpleName, String... simpleNames) {
 List<String> result = new ArrayList<>();
 result.add(packageName);
 result.add(simpleName);
 Collections.addAll(result, simpleNames);
 return new ClassName(result);
}

代码示例来源:origin: stackoverflow.com

class AnotherClass{
  private ClassName ref;

  AnotherClass(){
     ref = new ClassName()
  }

  private void someActionPerformed(java.awt.event.ActionEvent evt) {
    ref.methodName();
  }
}

代码示例来源:origin: stackoverflow.com

public class Main {
  public static void main(String[] args) {
    ClassName className = new ClassName();
    Object a = new Object(); // replace with correct a
    Object b = new Object(); // replace with correct b
    double v = className.functionName().main(a,b);
    className.output.display(v);
  }
}

代码示例来源:origin: stackoverflow.com

ClassName instanceName;

//Create a new instance
instanceName = new ClassName(); 
instanceName.methodName();

//Create a new instance
instanceName = new ClassName(); 
instanceName.methodName(); //Will now use the second instance

代码示例来源:origin: stackoverflow.com

ClassName obj = new ClassName("obj");

if (obj.getName().equals(...))
  ...

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Returns a new {@link ClassName} instance for the specified {@code name} as nested inside this
 * class.
 */
public ClassName nestedClass(String name) {
 checkNotNull(name, "name == null");
 List<String> result = new ArrayList<>(names.size() + 1);
 result.addAll(names);
 result.add(name);
 return new ClassName(result);
}

代码示例来源:origin: stackoverflow.com

final ClassName wrapped = builder.buildClassName();
ClassName c = new ClassName() {
  public void passedThroughMethod1() { wrapped.passedThroughMethod1() }
  public void overridenMethod() { method body }
  public void passedThroughMethod2() { wrapped.passedThroughMethod2() }
};

代码示例来源:origin: stackoverflow.com

public <T> List<T> methodeName(String path, Class<T> clazz) throws FileNotFoundException {
  CSVReader reader = new CSVReader(new FileReader(path), ',', '\"');

  HeaderColumnNameTranslateMappingStrategy<T> strat = 
    new HeaderColumnNameTranslateMappingStrategy<T>();
  strat.setType(clazz);
}

...

ClassName cn = new ClassName();
List<Foo> foos = cn.methodeName(somePath, Foo.class);

相关文章