本文整理汇总了Java中org.openide.util.Parameters.notEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.notEmpty方法的具体用法?Java Parameters.notEmpty怎么用?Java Parameters.notEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.util.Parameters
的用法示例。
在下文中一共展示了Parameters.notEmpty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getField
import org.openide.util.Parameters; //导入方法依赖的package包/类
/**
* Gets the variable tree representing the first field of the given type in
* our class.
*
* @param fieldTypeFqn the fully qualified name of the field's type.
* @return the variable tree or null if no matching field was found.
*/
protected VariableTree getField(final String fieldTypeFqn){
Parameters.notEmpty("fieldTypeFqn", fieldTypeFqn); //NOI18N
for (Tree member : getClassTree().getMembers()){
if (Tree.Kind.VARIABLE == member.getKind()){
VariableTree variable = (VariableTree) member;
TreePath path = getWorkingCopy().getTrees().getPath(getWorkingCopy().getCompilationUnit(), variable);
TypeMirror variableType = getWorkingCopy().getTrees().getTypeMirror(path);
if (fieldTypeFqn.equals(variableType.toString())){
return variable;
}
}
}
return null;
}
示例2: getClassSourceGroup
import org.openide.util.Parameters; //导入方法依赖的package包/类
/**
* Gets the {@link SourceGroup} of the given <code>project</code> which contains the
* given <code>fqClassName</code>.
*
* @param project the project; must not be null.
* @param fqClassName the fully qualified name of the class whose
* source group to get; must not be empty or null.
* @return the source group containing the given <code>fqClassName</code> or <code>null</code>
* if the class was not found in the source groups of the project.
*/
public static SourceGroup getClassSourceGroup(Project project, String fqClassName) {
Parameters.notNull("project", project); //NOI18N
Parameters.notEmpty("fqClassName", fqClassName); //NOI18N
String classFile = fqClassName.replace('.', '/') + ".java"; // NOI18N
SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
for (SourceGroup sourceGroup : sourceGroups) {
FileObject classFO = sourceGroup.getRootFolder().getFileObject(classFile);
if (classFO != null) {
return sourceGroup;
}
}
return null;
}
示例3: getPropertyName
import org.openide.util.Parameters; //导入方法依赖的package包/类
/**
* Gets the name of the property associated with the given accessor.
*
* @param accessor the name of the accessor method of the property. Must follow the JavaBeans
* naming conventions, i.e. start with 'get/set/is' followed by an uppercase letter,
* otherwise it is assumed that the name of the property directly matches with
* the getter. Must not be null or empty.
*
* @return the property name resolved from the given <code>getter</code>, i.e.
* if the given arg was <code>getProperty</code>, this method will return
* <code>property</code>.
*/
public static String getPropertyName(String accessor){
Parameters.notEmpty("accessor", accessor); //NO18N
int prefixLength = getPrefixLength(accessor);
String withoutPrefix = accessor.substring(prefixLength);
char firstChar = withoutPrefix.charAt(0);
if (!Character.isUpperCase(firstChar)){
return accessor;
}
return Character.toLowerCase(firstChar) + withoutPrefix.substring(1);
}
示例4: getAnnotation
import org.openide.util.Parameters; //导入方法依赖的package包/类
/**
* Gets the element representing an annotation of the given type. Searches annotations
* declared on class, fields and methods (in that order).
* @param annotationTypeFqn the fully qualified name of the annotation's type.
* @return the element or null if no matching annotation was found.
*/
protected Element getAnnotation(final String annotationTypeFqn){
Parameters.notEmpty("annotationTypeFqn", annotationTypeFqn); //NOI18N
TypeElement annotationType = asTypeElement(annotationTypeFqn);
TypeElement classElement = getClassElement();
List<Element> elements = new ArrayList<Element>();
elements.add(classElement);
elements.addAll(ElementFilter.fieldsIn(classElement.getEnclosedElements()));
elements.addAll(ElementFilter.methodsIn(classElement.getEnclosedElements()));
return checkElementsForAnnotationType(elements, annotationType);
}
示例5: setMIMEType
import org.openide.util.Parameters; //导入方法依赖的package包/类
/** Registers specified extension to be recognized as specified MIME type.
* If MIME type parameter is null, it cancels previous registration.
* Note that you may register a case-sensitive extension if that is
* relevant (for example {@literal *.C} for C++) but if you register
* a lowercase extension it will by default apply to uppercase extensions
* too on Windows.
* @param extension the file extension to be registered
* @param mimeType the MIME type to be registered for the extension or {@code null} to deregister
* @see #getMIMEType(FileObject)
* @see #getMIMETypeExtensions(String)
*/
public static void setMIMEType(String extension, String mimeType) {
Parameters.notEmpty("extension", extension); //NOI18N
final Map<String, Set<String>> mimeToExtensions = new HashMap<String, Set<String>>();
FileObject userDefinedResolverFO = MIMEResolverImpl.getUserDefinedResolver();
if (userDefinedResolverFO != null) {
// add all previous content
mimeToExtensions.putAll(MIMEResolverImpl.getMIMEToExtensions(userDefinedResolverFO));
// exclude extension possibly registered for other MIME types
for (Set<String> extensions : mimeToExtensions.values()) {
extensions.remove(extension);
}
}
if (mimeType != null) {
// add specified extension to our structure
Set<String> previousExtensions = mimeToExtensions.get(mimeType);
if (previousExtensions != null) {
previousExtensions.add(extension);
} else {
mimeToExtensions.put(mimeType, Collections.singleton(extension));
}
}
if (MIMEResolverImpl.storeUserDefinedResolver(mimeToExtensions)) {
MIMESupport.resetCache();
}
MIMESupport.freeCaches();
}
示例6: ResizeOption
import org.openide.util.Parameters; //导入方法依赖的package包/类
private ResizeOption( Type type, String displayName, int width, int height, boolean showInToolbar, boolean isDefault ) {
Parameters.notEmpty( "displayName", displayName ); //NOI18N
Parameters.notNull( "type", type ); //NOI18N
this.type = type;
this.displayName = displayName;
this.width = width;
this.height = height;
this.showInToolbar = showInToolbar;
this.isDefault = isDefault;
}
示例7: testNotEmpty
import org.openide.util.Parameters; //导入方法依赖的package包/类
public void testNotEmpty() throws Exception {
assertNPEOnNull(Parameters.class.getMethod("notEmpty", CharSequence.class, CharSequence.class));
try {
Parameters.notEmpty("param", "");
fail("Should have thrown IAE");
} catch (IllegalArgumentException e) {}
Parameters.notEmpty("param", "foo");
}
示例8: checkFQN
import org.openide.util.Parameters; //导入方法依赖的package包/类
private static void checkFQN(String fqn){
Parameters.notEmpty("fqn", fqn); //NOI18N
if (!isValidPackageName(fqn)){
throw new IllegalArgumentException("The given fqn [" + fqn + "] does not represent a fully qualified class name"); //NOI18N
}
}
示例9: getValue
import org.openide.util.Parameters; //导入方法依赖的package包/类
public String getValue (final String key) {
Parameters.notEmpty("key", key); //NOI18N
return this.spi.getValue (key);
}
示例10: getValues
import org.openide.util.Parameters; //导入方法依赖的package包/类
public String[] getValues (final String key) {
Parameters.notEmpty("key", key); //NOI18N
return this.spi.getValues (key);
}
示例11: renameClass
import org.openide.util.Parameters; //导入方法依赖的package包/类
/**
* Constructs a new fully qualified name for the given <code>newName</code>.
*
* @param originalFullyQualifiedName the old fully qualified name of the class.
* @param newName the new unqualified name of the class.
*
* @return the new fully qualified name of the class.
*/
public static String renameClass(String originalFullyQualifiedName, String newName){
Parameters.notEmpty("originalFullyQualifiedName", originalFullyQualifiedName); //NO18N
Parameters.notEmpty("newName", newName); //NO18N
int lastDot = originalFullyQualifiedName.lastIndexOf('.');
return (lastDot <= 0) ? newName : originalFullyQualifiedName.substring(0, lastDot + 1) + newName;
}
示例12: addPair
import org.openide.util.Parameters; //导入方法依赖的package包/类
/**
* Add a [key,value] pair to this document. Note that the document really
* contains a multi-map, so it is okay and normal to call addPair multiple
* times with the same key. This just adds the value to the set of values
* associated with the key.
*
* @param key The key that you will later search by. Note that you are NOT
* allowed to use the keys <code>filename</code> or <code>timestamp</code>
* since these are reserved (and in fact used) by GSF.
* @param value The value that will be retrieved for this key
* @param searchable A boolean which if set to true will store the pair with
* an indexed/searchable field key, otherwise with an unindexed field (that cannot be
* searched). You <b>must</b> be consistent in how keys are identified
* as searchable; the same key must always be referenced with the same
* value for searchable when pairs are added (per document).
*/
public void addPair( /*@NonNull*/ String key, /*@NonNull*/ String value, boolean searchable, boolean stored) {
Parameters.notNull("key", key); //NOI18N
Parameters.notEmpty("key", key); //NOI18N
Parameters.notNull("value", value); //NOI18N
this.spi.addPair(key, value, searchable, stored);
}
示例13: ComparisonFailure
import org.openide.util.Parameters; //导入方法依赖的package包/类
/**
* Constructs a new ComparisonFailure.
* @param expected the expected value.
* @param actual the actual value.
* @param mimeType the mime type for the comparison; must not be <code>null</code>
* or an empty String.
*/
public ComparisonFailure(String expected, String actual, String mimeType) {
Parameters.notEmpty("mimeType", mimeType);
this.expected = expected;
this.actual = actual;
this.mimeType = mimeType;
}