Codota Logo
FqnIndexer
Code IndexAdd Codota to your IDE (free)

How to use
FqnIndexer
in
rocks.inspectit.server.instrumentation.classcache.index

Best Java code snippets using rocks.inspectit.server.instrumentation.classcache.index.FqnIndexer (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: inspectIT/inspectIT

  @Override
  public Collection<Type> call() throws Exception {
    return fqnIndexer.findAll();
  }
});
origin: inspectIT/inspectIT

  @Override
  public Collection<Type> call() throws Exception {
    return fqnIndexer.findByPattern(pattern);
  }
});
origin: inspectIT/inspectIT

  @Override
  public ImmutableType call() throws Exception {
    return fqnIndexer.lookup(fqn);
  }
});
origin: inspectIT/inspectIT

/**
 * Finds type by exact FQN name.
 *
 * @param fqn
 *            Fully qualified class name.
 * @return Returns type or <code>null</code> if it can not be found.
 */
public E lookup(String fqn) {
  int index = findRetrieveIndexFor(fqn);
  return getAt(index);
}
origin: inspectIT/inspectIT

/**
 * Finds all {@link NonPrimitiveType}s that start with given string.
 *
 * @param fqnWildCard
 *            String that class should start with.
 * @return All types starting with the given string.
 */
public Collection<E> findStartsWith(String fqnWildCard) {
  long minMaxIndex = findStartsWithMinMaxIndexes(fqnWildCard);
  int min = getLowerInt(minMaxIndex);
  int max = getUpperInt(minMaxIndex);
  if (min < 0) {
    return Collections.emptyList();
  }
  int size = size();
  List<E> results = new ArrayList<>((max - min) + 1);
  for (int i = min; (i <= max) && (max < size); i++) {
    results.add(getAt(i));
  }
  return results;
}
origin: inspectIT/inspectIT

/**
 * {@inheritDoc}
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  int size = size();
  for (int i = 0; i < size; i++) {
    sb.append("[" + i + "] = " + getAt(i).getFQN() + "\n");
  }
  return sb.toString();
}
origin: inspectIT/inspectIT

@Test
public void sameFqnTwice() {
  ClassType stringType1 = new ClassType(String.class.getName());
  ClassType stringType2 = new ClassType(String.class.getName());
  indexer.index(stringType1);
  indexer.index(stringType2);
  ClassType lookup = indexer.lookup(String.class.getName());
  assertThat(indexer, hasSize(1));
  assertThat(lookup == stringType2, is(true));
}
origin: inspectIT/inspectIT

@Test
public void wildcardPattern() {
  ClassType stringType = new ClassType(String.class.getName());
  ClassType objectType = new ClassType(Object.class.getName());
  ClassType thisType = new ClassType(FqnIndexer.class.getName());
  indexer.index(stringType);
  indexer.index(thisType);
  indexer.index(new ClassType("a"));
  indexer.index(new ClassType("java.nolang"));
  indexer.index(objectType);
  WildcardMatchPattern wildcardMatchPattern = new WildcardMatchPattern("java*lang");
  Collection<ClassType> results = indexer.findByPattern(wildcardMatchPattern);
  assertThat(results, hasSize(1));
  for (ClassType classType : results) {
    assertThat(wildcardMatchPattern.match(classType.getFQN()), is(true));
  }
}
origin: inspectIT/inspectIT

  @Test
  public void notFound() {
    ClassType stringType = new ClassType(String.class.getName());
    ClassType objectType = new ClassType(Object.class.getName());
    ClassType thisType = new ClassType(FqnIndexer.class.getName());
    indexer.index(stringType);
    indexer.index(thisType);
    indexer.index(new ClassType("a"));
    indexer.index(new ClassType("java.nolang"));
    indexer.index(objectType);
    // middle
    Collection<ClassType> results = indexer.findStartsWith("aa");
    assertThat(results, is(empty()));
    results = indexer.findStartsWith("java.lang.something");
    assertThat(results, is(empty()));
    results = indexer.findStartsWith("ww");
    assertThat(results, is(empty()));
  }
}
origin: inspectIT/inspectIT

int size = size();
int minIndex = -1;
int maxIndex = -1;
  int mid = midpoint(min, max);
  String fqn = getAt(mid).getFQN();
  if (fqn.startsWith(fqnWildCard)) {
  return pack(0, -1);
  int mid = midpoint(min, max);
  int compare = getAt(mid).getFQN().startsWith(fqnWildCard) ? 1 : -1;
  int mid = midpoint(min, max);
  int compare = getAt(mid).getFQN().startsWith(fqnWildCard) ? -1 : 1;
return pack(maxIndex, minIndex);
origin: inspectIT/inspectIT

results = findStartsWith(startsWithCriteria);
E type = lookup(template);
if (null != type) {
  results = new ArrayList<>(1);
origin: inspectIT/inspectIT

  @Test
  public void findAll() {
    ClassType stringType = new ClassType(String.class.getName());
    ClassType objectType = new ClassType(Object.class.getName());
    ClassType thisType = new ClassType(FqnIndexer.class.getName());
    indexer.index(stringType);
    indexer.index(thisType);
    indexer.index(objectType);
    Collection<ClassType> types = indexer.findAll();
    assertThat(types, hasSize(3));
    assertThat(types, hasItem(stringType));
    assertThat(types, hasItem(objectType));
    assertThat(types, hasItem(thisType));
  }
}
origin: inspectIT/inspectIT

/**
 * Finds index for a FQN to retrieve.
 *
 * @param fqn
 *            String representing the FQN.
 * @return Index where element should be retrieved from or negative value if one can not be
 *         located.
 */
private int findRetrieveIndexFor(String fqn) {
  int size = size();
  int min = 0;
  int max = size - 1;
  while (max >= min) {
    int mid = midpoint(min, max);
    int compare = getAt(mid).getFQN().compareTo(fqn);
    // if no difference then we have it
    if (0 == compare) {
      return mid;
    }
    // otherwise adapt min and max
    min = (compare < 0) ? mid + 1 : min;
    max = (compare > 0) ? mid - 1 : max;
  }
  return -1;
}
origin: inspectIT/inspectIT

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
public void informNodeChange(NodeEvent event) {
  if (NodeEventType.NEW.equals(event.getEventType())) {
    index((E) event.getType());
  } else if (NodeEventType.REMOVED.equals(event.getEventType())) {
    remove(event.getType());
  }
}
origin: inspectIT/inspectIT

/**
 * Index one type.
 *
 * @param type
 *            Type to index.
 */
void index(E type) {
  addOrUpdate(type);
}
origin: inspectIT/inspectIT

@Test
public void notFound() {
  ClassType stringType = new ClassType(String.class.getName());
  ClassType objectType = new ClassType(Object.class.getName());
  ClassType thisType = new ClassType(FqnIndexer.class.getName());
  indexer.index(stringType);
  indexer.index(thisType);
  indexer.index(objectType);
  ClassType lookup = indexer.lookup("nonExistingType");
  assertThat(indexer, hasSize(3));
  assertThat(lookup, is(nullValue()));
}
origin: inspectIT/inspectIT

@Test
public void wildcardPatternStarFirstLast() {
  ClassType stringType = new ClassType(String.class.getName());
  ClassType objectType = new ClassType(Object.class.getName());
  ClassType thisType = new ClassType(FqnIndexer.class.getName());
  indexer.index(stringType);
  indexer.index(thisType);
  indexer.index(new ClassType("a"));
  indexer.index(new ClassType("java.nolang"));
  indexer.index(objectType);
  WildcardMatchPattern wildcardMatchPattern = new WildcardMatchPattern("*lang*");
  Collection<ClassType> results = indexer.findByPattern(wildcardMatchPattern);
  assertThat(results, hasSize(3));
  for (ClassType classType : results) {
    assertThat(wildcardMatchPattern.match(classType.getFQN()), is(true));
  }
}
origin: inspectIT/inspectIT

@Test
public void found() {
  ClassType stringType = new ClassType(String.class.getName());
  ClassType objectType = new ClassType(Object.class.getName());
  ClassType thisType = new ClassType(FqnIndexer.class.getName());
  indexer.index(stringType);
  indexer.index(thisType);
  indexer.index(new ClassType("a"));
  indexer.index(new ClassType("java.nolang"));
  indexer.index(objectType);
  // middle
  Collection<ClassType> results = indexer.findStartsWith("java.lang");
  assertThat(results, hasSize(2));
  for (ClassType classType : results) {
    assertThat(classType.getFQN().startsWith("java.lang"), is(true));
  }
  // end
  results = indexer.findStartsWith("java.nolang");
  assertThat(results, hasSize(1));
  for (ClassType classType : results) {
    assertThat(classType.getFQN().startsWith("java.nolang"), is(true));
  }
  // begin
  results = indexer.findStartsWith("a");
  assertThat(results, hasSize(1));
  for (ClassType classType : results) {
    assertThat(classType.getFQN().startsWith("a"), is(true));
  }
}
origin: inspectIT/inspectIT

  @Test
  public void equalsPatternNonExistingElement() {
    EqualsMatchPattern equalsMatchPattern = new EqualsMatchPattern("whatever");
    Collection<ClassType> results = indexer.findByPattern(equalsMatchPattern);
    assertThat(results, is(empty()));
  }
}
origin: inspectIT/inspectIT

  @Test
  public void replace() {
    ClassType stringType = new ClassType(String.class.getName());
    ClassType objectType = new ClassType(Object.class.getName());
    ClassType thisType = new ClassType(FqnIndexer.class.getName());
    ClassType secondObjectType = new ClassType(Object.class.getName());
    indexer.index(stringType);
    indexer.index(thisType);
    indexer.index(objectType);
    indexer.index(secondObjectType);
    ClassType lookup = indexer.lookup(Object.class.getName());
    assertThat(indexer, hasSize(3));
    assertThat(System.identityHashCode(lookup), is(System.identityHashCode(secondObjectType)));
  }
}
rocks.inspectit.server.instrumentation.classcache.indexFqnIndexer

Javadoc

Fast type indexer by FQN name. Indexer can locate types by exact name or by startsWith approach.

Note that this indexer should not be used with multiple threads reading and writing. Multiple threads reading is OK.

Most used methods

  • findAll
    Finds all indexed types.
  • findByPattern
    Finds types by IMatchPattern. FQN of each returned type will match the given pattern.
  • findStartsWith
    Finds all NonPrimitiveTypes that start with given string.
  • index
    Index one type.
  • lookup
    Finds type by exact FQN name.
  • addOrUpdate
  • findRetrieveIndexFor
    Finds index for a FQN to retrieve.
  • findStartsWithMinMaxIndexes
    Find elements that starts with given String.
  • getAt
  • getLowerInt
  • getUpperInt
  • midpoint
  • getUpperInt,
  • midpoint,
  • pack,
  • remove,
  • size

Popular in Java

  • Making http post requests using okhttp
  • getExternalFilesDir (Context)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • getSharedPreferences (Context)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • ArrayList (java.util)
    Resizable-array implementation of the List interface. Implements all optional list operations, and p
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Collectors (java.util.stream)
  • ImageIO (javax.imageio)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now