All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.zerobuilder.compiler.common.Visibility Maven / Gradle / Ivy

There is a newer version: 1.644
Show newest version
package net.zerobuilder.compiler.common;

import javax.lang.model.element.Element;
import javax.lang.model.element.Modifier;
import java.util.Objects;
import java.util.Set;

import static javax.lang.model.element.ElementKind.PACKAGE;

/**
 * Guava-free versions of some helpers from auto-common.
 */
enum Visibility {
  PRIVATE,
  DEFAULT,
  PROTECTED,
  PUBLIC;

  static Visibility ofElement(Element element) {
    Objects.requireNonNull(element);
    if (element.getKind().equals(PACKAGE)) {
      return PUBLIC;
    }
    Set modifiers = element.getModifiers();
    if (modifiers.contains(Modifier.PRIVATE)) {
      return PRIVATE;
    } else if (modifiers.contains(Modifier.PROTECTED)) {
      return PROTECTED;
    } else if (modifiers.contains(Modifier.PUBLIC)) {
      return PUBLIC;
    } else {
      return DEFAULT;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy