Java Code Examples for org.jetbrains.annotations.NonNls

The following are top voted examples for showing how to use org.jetbrains.annotations.NonNls. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: strictfp-back-end   File: Article.java   View source code 6 votes vote down vote up
public Article(
		int id,
		@NotNull @NonNls LocalDate publishTime,
		@NotNull Author author,
		@NotNull Set<Tag> tags,
		@NotNull @NonNls String title,
		@NotNull @NonNls String brief,
		@NotNull @NonNls String content,
		int up,
		int down,
		int click) {
	this.brief = brief;
	this.title = title;
	this.tags = tags;
	this.id = id;
	this.publishDate = publishTime;
	this.content = content;
	this.up = up;
	this.down = down;
	this.click = click;
	this.author = author;
}
 
Example 2
Project: AppleScript-IDEA   File: AppleScriptHandlerInterleavedParameters.java   View source code 6 votes vote down vote up
@Override
public PsiElement setName(@NonNls @NotNull String newElementName) throws IncorrectOperationException {
  //todo implement this via rename refactor: RenamePsiElementProcessor & RenameHandler for each distinct selector
  final int selectors = getParameters().size();
  final String[] selectorNames = newElementName.split(":");
  if (selectorNames.length == selectors) {
    for (int index = 0; index < selectors; index++) {
      AppleScriptIdentifier myId = getParameters().get(index).getSelectorNameIdentifier();
      final AppleScriptIdentifier idNew = AppleScriptPsiElementFactory.createIdentifierFromText(getProject(), selectorNames[index]);
      if (idNew != null) {
        myId.replace(idNew);
      }
    }
  } else {
    AppleScriptIdentifier myIdentifier = getParameters().get(0).getSelectorNameIdentifier();
    final AppleScriptIdentifier identifierNew = AppleScriptPsiElementFactory.createIdentifierFromText(getProject(), newElementName);
    if (identifierNew != null) {
      myIdentifier.replace(identifierNew);
    }
  }
  return this;
}
 
Example 3
Project: strictfp-back-end   File: VerifyAccount.java   View source code 6 votes vote down vote up
public boolean verifyZhihuImportance(@NotNull @NonNls String username) {
	try {
		IntTokenizer tokenizer = null;
		Document page = Jsoup.parse(
				new URL(String.format(ZhihuApiRoot,username)),
				5000
		);
		Elements root = page.select("div[class='meta']");
		tokenizer = IntTokenizer.of(root.text());
		int reputationPoint = tokenizer.nextToken();
		tokenizer.nextToken();
		int likesPoint = tokenizer.nextToken();
		return (reputationPoint >= 50 && likesPoint >= 40);
	} catch (IOException e) {
		throw new RuntimeException("unable to fetch data from zhihu", e);
	}
}
 
Example 4
Project: manifold-ij   File: ManShortNamesCache.java   View source code 6 votes vote down vote up
private void findPsiClasses( @NotNull @NonNls String name, @NotNull GlobalSearchScope scope, Set<PsiClass> psiClasses, ManModule start, ManModule module )
{
  for( ITypeManifold tm: module.getTypeManifolds() )
  {
    for( String fqn: tm.getAllTypeNames() )
    {
      String simpleName = ClassUtil.extractClassName( fqn );
      if( simpleName.equals( name ) )
      {
        PsiClass psiClass = ManifoldPsiClassCache.instance().getPsiClass( scope, module, fqn );
        if( psiClass == null )
        {
          return;
        }
        psiClasses.add( psiClass );
      }
    }
  }
  for( Dependency d : module.getDependencies() )
  {
    if( module == start || d.isExported() )
    {
      findPsiClasses( name, scope, psiClasses, start, (ManModule)d.getModule() );
    }
  }
}
 
Example 5
Project: strictfp-back-end   File: VerifyAccount.java   View source code 6 votes vote down vote up
public boolean verifyStackOverFlowAccount(@NotNull @NonNls String username) {
	try {
		String url = SOFApiRoot + String.format(
				"users?order=asc&min=%s&max=%s&sort=name&inname=%s&site=stackoverflow",
				username,
				username,
				username
		);
		HttpURLConnection conn = HttpURLConnection.class.cast(new URL(url).openConnection());
		if (conn.getResponseCode() != 200) return false;
		JSONTokener tokener = new JSONTokener(new GZIPInputStream(conn.getInputStream()));
		// note that it was compressed
		JSONObject object = JSONObject.class.cast(tokener.nextValue());
		conn.disconnect();
		return object.getJSONArray("items").length() != 0;
		// 特判一下吧还是。。昨晚查询不存在用户返回的是200 ...和一个json
		// 上面打这段注释的,没注意到我判断了返回的结果是否包含有效用户吗 =-= , bug 'fixed'
	} catch (IOException e) {
		throw new RuntimeException("unable to fetch data from stackoverflow", e);
	}
}
 
Example 6
Project: strictfp-back-end   File: MySqlAdapter.java   View source code 6 votes vote down vote up
@NotNull
	@Override
	public ResultSet select(
			@NotNull @NonNls String tableName,
			@Nullable @NonNls String columnName,
			@Nullable Pair... where) {
		StringBuilder deepDarkFantasy = new StringBuilder(getQueryString(tableName, columnName));
		if (where != null) {
			deepDarkFantasy
					.append(" WHERE ")
					.append(String.join(" AND ", (CharSequence[]) Pair.convert(where)));
		}
		return querySQL(deepDarkFantasy.toString());
/*
return statement.executeQuery("SELECT " +
		(columnName != null ? columnName : "*") +
		" FROM " + tableName +
		" WHERE " + String.join(" and ", Pair.convert(where))
		);
// NOTICE: HERE I IGNORED THE CASE THAT WHERE IS NULL
*/
	}
 
Example 7
Project: strictfp-back-end   File: Pair.java   View source code 6 votes vote down vote up
@Contract(pure = true)
@NotNull
@NonNls
public static String[] convert(Pair... origin) {
	String[] ret = new String[origin.length];
	for (int i = 0; i < ret.length; ++i) ret[i] = origin[i].getCombined();
	return ret;
}
 
Example 8
Project: strictfp-back-end   File: MySqlAdapter.java   View source code 5 votes vote down vote up
@Override
	public synchronized boolean insert(
			@NotNull @NonNls String tableName,
			@NotNull @NonNls String... value) {
		// TODO unsafe , needs to be fixed - phosphorus15
		try {
//			PreparedStatement preparedStatement = connection.prepareStatement();
			String boyNextDoor = "INSERT INTO " + tableName + " VALUES ( ";
			for (String val : value) execSQL(boyNextDoor + val + " )");
			return true;
		} catch (RuntimeException e) {
			return false;
		}
	}
 
Example 9
Project: strictfp-back-end   File: MySqlAdapter.java   View source code 5 votes vote down vote up
private MySqlAdapter(@NotNull @NonNls String url) {

		try {
			Class.forName("com.mysql.cj.jdbc.Driver");
			connection = DriverManager.getConnection(url, Constant.SERVER.DATABASE_USERNAME,
					Constant.SERVER.DATABASE_PASSWORD);
			connection.setAutoCommit(false);
			statement = connection.createStatement();
		} catch (Exception e) {
			throw new RuntimeException("cannot connect to the database!", e);
		}
	}
 
Example 10
Project: strictfp-back-end   File: Tools.java   View source code 5 votes vote down vote up
/**
 * an OI-style reading method
 *
 * @param content raw
 * @return parsed int
 */
@Contract(pure = true)
public static int getValidNumber(@NotNull @NonNls char[] content) {
	int index = 0;
	int result = 0;
	int current = content[index++];
	while (!(current >= '0' && current <= '9')) current = content[index++];
	while (index <= content.length && current >= '0' && current <= '9') {
		result = (result << 3) + (result << 1) + (current - '0'); // equal to result * 10
		if (index >= content.length) break;
		current = content[index++];
	}
	return result;
}
 
Example 11
Project: strictfp-back-end   File: MySqlAdapter.java   View source code 5 votes vote down vote up
@NotNull
@Override
public ResultSet querySQL(
		@NotNull @NonNls String sql) {
	try {
		logger.info("Run SQL statement: " + sql);
		return statement.executeQuery(sql);
	} catch (SQLException e) {
		e.printStackTrace();
		throw new RuntimeException("sql error!");
	}
}
 
Example 12
Project: manifold-ij   File: ManShortNamesCache.java   View source code 5 votes vote down vote up
@NotNull
@Override
public PsiClass[] getClassesByName( @NotNull @NonNls String name, @NotNull GlobalSearchScope scope )
{
  Set<PsiClass> psiClasses = new HashSet<>();
  for( ManModule module: ManTypeFinder.findModules( scope ) )
  {
    findPsiClasses( name, scope, psiClasses, module );
  }
  return psiClasses.toArray( new PsiClass[psiClasses.size()] );
}
 
Example 13
Project: magento2-phpstorm-plugin   File: LineMarkerXmlTagDecorator.java   View source code 5 votes vote down vote up
/**
 * Get line marker text. This method should be overridden to generate user-friendly XmlTag presentation.
 */
@Override
@NotNull
@NonNls
public String getName() {
    return String.format("%s [%s] - %s", getComponentName(), getAreaName(), getDescription());
}
 
Example 14
Project: magento2-phpstorm-plugin   File: LineMarkerXmlTagDecorator.java   View source code 5 votes vote down vote up
@Override
@Contract(
        pure = true
)
public boolean textMatches(@NotNull @NonNls CharSequence charSequence) {
    return xmlTag.textMatches(charSequence);
}
 
Example 15
Project: strictfp-back-end   File: DatabaseAdapter.java   View source code 5 votes vote down vote up
@NotNull
default ResultSet selectWithExtraInfo(
		@NotNull @NonNls String tableName,
		@Nullable @NonNls String columnName,
		@NotNull @NonNls String extraInfo) {
	return querySQL(getQueryString(tableName, columnName) + extraInfo);
}
 
Example 16
Project: magento2-phpstorm-plugin   File: TypeConfigurationIndex.java   View source code 5 votes vote down vote up
@Override
@NotNull
@NonNls
public String getName() {
    String preference = xmlTag.getAttributeValue(TYPE_ATTRIBUTE);
    if (preference != null) {
        return String.format("[%s] preference %s", getAreaName(), preference);
    }
    return xmlTag.getName();
}
 
Example 17
Project: magento2-phpstorm-plugin   File: WebApiTypeIndex.java   View source code 5 votes vote down vote up
@Override
@NotNull
@NonNls
public String getName() {
    String httpMethod = this.xmlTag.getAttributeValue("method");
    String route = this.xmlTag.getAttributeValue("url");
    if (httpMethod != null && route != null) {
        return String.format("  %-7s %s", httpMethod, route);
    }
    return xmlTag.getName();
}
 
Example 18
Project: intellij-bpmn-editor   File: BPMNFileSchemaProvider.java   View source code 5 votes vote down vote up
private static XmlFile getReference(@NotNull @NonNls String url, @NotNull Module module) {
    if (url.equalsIgnoreCase("http://bpmn.sourceforge.net")) {
        return null;
    }
    final URL resource = BPMNFileSchemaProvider.class.getResource(BPMNModelConstants.BPMN_SCHEMA_BASEURI + BPMNModelConstants.BPMN_SYSTEM_ID);
    final VirtualFile fileByURL = VfsUtil.findFileByURL(resource);
    if (fileByURL == null) {
        return null;
    }

    PsiFile psiFile = PsiManager.getInstance(module.getProject()).findFile(fileByURL);
    return (XmlFile) psiFile.copy();
}
 
Example 19
Project: hybris-integration-intellij-idea-plugin   File: TypeSystemConverterBase.java   View source code 5 votes vote down vote up
@Nullable
@Override
public final DOM fromString(
    @Nullable @NonNls final String s, final ConvertContext context
) {
    if (StringUtil.isEmpty(s)) {
        return null;
    }
    return searchForName(s, context, TSMetaModelAccess.getInstance(context.getProject()).
        getTypeSystemMeta(context.getFile()));
}
 
Example 20
Project: hybris-integration-intellij-idea-plugin   File: CompositeConverter.java   View source code 5 votes vote down vote up
@Nullable
@Override
public DOM fromString(
    @Nullable @NonNls final String s, final ConvertContext context
) {
    for (TypeSystemConverterBase<? extends DOM> next : myDelegates) {
        final DOM nextResult = next.fromString(s, context);
        if (nextResult != null) {
            return nextResult;
        }
    }
    return null;
}
 
Example 21
Project: educational-plugin   File: EduIntellijUtils.java   View source code 5 votes vote down vote up
public static void addTemplate(@NotNull final Project project, @NotNull VirtualFile baseDir, @NotNull @NonNls final String templateName) {
        final FileTemplate template = FileTemplateManager.getInstance(project).getInternalTemplate(templateName);
        final PsiDirectory projectDir = PsiManager.getInstance(project).findDirectory(baseDir);
        if (projectDir == null) return;
        try {
//            PsiDirectory utilDir = projectDir.findSubdirectory("util");
//            if (utilDir == null) {
//                utilDir = projectDir.createSubdirectory("util");
//            }
            FileTemplateUtil.createFromTemplate(template, templateName, null, projectDir);
        } catch (Exception exception) {
            LOG.error("Failed to create from file template ", exception);
        }

    }
 
Example 22
Project: yii2support   File: TestDataSource.java   View source code 4 votes vote down vote up
@Override
public PsiElement setName(@NonNls @NotNull String s) throws IncorrectOperationException {
    return null;
}
 
Example 23
Project: strictfp-back-end   File: WriterType.java   View source code 4 votes vote down vote up
public boolean addRefuse(@NotNull @NonNls String power) {
	return powerMap.put(power, false);
}
 
Example 24
Project: yii2support   File: TestNamespace.java   View source code 4 votes vote down vote up
@Override
public PsiElement setName(@NonNls @NotNull String s) throws IncorrectOperationException {
    return null;
}
 
Example 25
Project: sercapnp   File: CapnpTokenType.java   View source code 4 votes vote down vote up
public CapnpTokenType(@NotNull @NonNls String debugName) {
    super(debugName, CapnpLanguage.INSTANCE);
}
 
Example 26
Project: yii2support   File: TestColumn.java   View source code 4 votes vote down vote up
@Override
public PsiElement setName(@NonNls @NotNull String s) throws IncorrectOperationException {
    return null;
}
 
Example 27
Project: strictfp-back-end   File: Pair.java   View source code 4 votes vote down vote up
public Pair(
		@NotNull @NonNls String key,
		@NotNull @NonNls String value) {
	this.key = key;
	this.value = value;
}
 
Example 28
Project: GitHub   File: Timber.java   View source code 4 votes vote down vote up
/** Log a verbose message with optional format args. */
public static void v(@NonNls String message, Object... args) {
  TREE_OF_SOULS.v(message, args);
}
 
Example 29
Project: GitHub   File: Timber.java   View source code 4 votes vote down vote up
/** Log a verbose exception and a message with optional format args. */
public static void v(Throwable t, @NonNls String message, Object... args) {
  TREE_OF_SOULS.v(t, message, args);
}
 
Example 30
Project: GitHub   File: Timber.java   View source code 4 votes vote down vote up
/** Log a debug exception and a message with optional format args. */
public static void d(Throwable t, @NonNls String message, Object... args) {
  TREE_OF_SOULS.d(t, message, args);
}
 
Example 31
Project: GitHub   File: Timber.java   View source code 4 votes vote down vote up
/** Log an info message with optional format args. */
public static void i(@NonNls String message, Object... args) {
  TREE_OF_SOULS.i(message, args);
}
 
Example 32
Project: GitHub   File: Timber.java   View source code 4 votes vote down vote up
/** Log an info exception and a message with optional format args. */
public static void i(Throwable t, @NonNls String message, Object... args) {
  TREE_OF_SOULS.i(t, message, args);
}
 
Example 33
Project: GitHub   File: Timber.java   View source code 4 votes vote down vote up
/** Log a warning message with optional format args. */
public static void w(@NonNls String message, Object... args) {
  TREE_OF_SOULS.w(message, args);
}
 
Example 34
Project: idea-onescript   File: OneScriptTokenType.java   View source code 4 votes vote down vote up
public OneScriptTokenType(@NotNull @NonNls String debugName) {
    super(debugName, OneScriptLanguage.INSTANCE);
}
 
Example 35
Project: strictfp-back-end   File: Tag.java   View source code 4 votes vote down vote up
@NotNull
@NonNls
@Override
public String toString() {
	return getName();
}
 
Example 36
Project: strictfp-back-end   File: DatabaseAdapter.java   View source code 4 votes vote down vote up
@NotNull
ResultSet querySQL(@NotNull @NonNls String sql);
 
Example 37
Project: GitHub   File: Timber.java   View source code 4 votes vote down vote up
/** Log an assert message with optional format args. */
public static void wtf(@NonNls String message, Object... args) {
  TREE_OF_SOULS.wtf(message, args);
}
 
Example 38
Project: GitHub   File: Timber.java   View source code 4 votes vote down vote up
/** Log an assert exception and a message with optional format args. */
public static void wtf(Throwable t, @NonNls String message, Object... args) {
  TREE_OF_SOULS.wtf(t, message, args);
}
 
Example 39
Project: GitHub   File: Timber.java   View source code 4 votes vote down vote up
/** Log at {@code priority} a message with optional format args. */
public static void log(int priority, @NonNls String message, Object... args) {
  TREE_OF_SOULS.log(priority, message, args);
}
 
Example 40
Project: strictfp-back-end   File: VerifyAccount.java   View source code 4 votes vote down vote up
public boolean verifyZhihuAccount(@NotNull @NonNls String username) {
	return verify("https://www.zhihu.com/people/", username);
	//FIXME: 由于严重违反知乎社区规范,该用户帐号已被停用。 这个是返回200的,测试账号fu-qian-yi-55
	//回上 , 这个账号测试返回404 。。。。。 具体去看test case
}