@@ -0,0 +1,2346 @@
+/*%0A * Copyright 2012-2014 JetBrains s.r.o%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage jetbrains.jetpad.base;%0A%0Aimport com.google.common.base.Objects;%0Aimport com.google.common.base.Predicate;%0Aimport com.google.common.base.Strings;%0A%0Apublic class Validators %7B%0A  private static final Predicate%3CString%3E IDENTIFIER = new Predicate%3CString%3E() %7B%0A    @Override%0A    public boolean apply(String input) %7B%0A      if (input == null) return false;%0A      if (input.isEmpty()) return false;%0A%0A      for (int i = 0; i %3C input.length(); i++) %7B%0A        char ch = input.charAt(i);%0A        if (i == 0 && Character.isDigit(ch)) return false;%0A        if (!Character.isLetter(ch) && !Character.isDigit(ch) && ch != '_') return false;%0A      %7D%0A%0A      return true;%0A    %7D%0A  %7D;%0A  private static final Predicate%3CString%3E INTEGER = new Predicate%3CString%3E() %7B%0A    @Override%0A    public boolean apply(String input) %7B%0A      if (Strings.isNullOrEmpty(input)) return false;%0A      for (int i = 0; i %3C input.length(); i++) %7B%0A        if (!Character.isDigit(input.charAt(i))) return false;%0A      %7D%0A      try %7B%0A        Integer.parseInt(input);%0A        return true;%0A      %7D catch (NumberFormatException e) %7B%0A        return false;%0A      %7D%0A    %7D%0A  %7D;%0A  private static final Predicate%3CString%3E BOOL = new Predicate%3CString%3E() %7B%0A    @Override%0A    public boolean apply(String input) %7B%0A      return %22true%22.equals(input) %7C%7C %22false%22.equals(input);%0A    %7D%0A  %7D;%0A%0A  public static Predicate%3CString%3E identifier() %7B%0A    return IDENTIFIER;%0A  %7D%0A%0A  public static Predicate%3CString%3E integer() %7B%0A    return INTEGER;%0A  %7D%0A%0A  public static Predicate%3CString%3E bool() %7B%0A    return BOOL;%0A  %7D%0A%0A  public static %3CT%3E Predicate%3CT%3E equalsTo(final T value) %7B%0A    return new Predicate%3CT%3E() %7B%0A      @Override%0A      public boolean apply(T input) %7B%0A        return Objects.equal(input, value);%0A      %7D%0A    %7D;%0A  %7D%0A%7D

move validators to a more appropriate place