// Path: src/main/java/org/fest/util/Preconditions.java
// public static @NotNull <T> T checkNotNull(@Nullable T reference) {
//   if (reference == null) {
//     throw new NullPointerException();
//   }
//   return reference;
// }
// 
// Path: src/main/java/org/fest/util/Preconditions.java
// public static @NotNull String checkNotNullOrEmpty(@Nullable String s) {
//   String checked = checkNotNull(s);
//   if (checked.isEmpty()) {
//     throw new IllegalArgumentException();
//   }
//   return checked;
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @Nullable String quote(@Nullable String s) {
//   return s != null ? String.format("'%s'", s) : null;
// }


import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import static java.lang.reflect.Modifier.isPublic;
import static java.util.Locale.ENGLISH;
import static org.fest.util.Preconditions.checkNotNull;
import static org.fest.util.Preconditions.checkNotNullOrEmpty;
import static org.fest.util.Strings.quote;
  public static @NotNull PropertyDescriptor getProperty(@NotNull String propertyName, @NotNull Object target) {
    checkNotNullOrEmpty(propertyName);
    checkNotNull(target);
    BeanInfo beanInfo;
    Class<?> type = target.getClass();
    try {
      beanInfo = Introspector.getBeanInfo(type);
    } catch (Throwable t) {
      String msg = String.format("Unable to get BeanInfo for type %s", type.getName());
      throw new IntrospectionError(checkNotNull(msg), t);
    }
    for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) {
      if (propertyName.equals(descriptor.getName())) {
        return descriptor;
      }
    }
    throw propertyNotFoundError(propertyName, target);
  }

  private static @NotNull IntrospectionError propertyNotFoundError(@NotNull String propertyName,
                                                                   @NotNull Object target) {
    Method getter = findGetter(propertyName, target);
    String format;
    if (getter == null) {
      format = "No getter for property %s in %s";
    } else if (!isPublic(getter.getModifiers())) {
      format = "No public getter for property %s in %s";
    } else {
      format = "Unable to find property %s in %s";
    }
// Path: src/main/java/org/fest/util/Preconditions.java
// public static @NotNull <T> T checkNotNull(@Nullable T reference) {
//   if (reference == null) {
//     throw new NullPointerException();
//   }
//   return reference;
// }
// 
// Path: src/main/java/org/fest/util/Preconditions.java
// public static @NotNull String checkNotNullOrEmpty(@Nullable String s) {
//   String checked = checkNotNull(s);
//   if (checked.isEmpty()) {
//     throw new IllegalArgumentException();
//   }
//   return checked;
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @Nullable String quote(@Nullable String s) {
//   return s != null ? String.format("'%s'", s) : null;
// }


// Path: src/main/java/org/fest/util/Introspection.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import static java.lang.reflect.Modifier.isPublic;
import static java.util.Locale.ENGLISH;
import static org.fest.util.Preconditions.checkNotNull;
import static org.fest.util.Preconditions.checkNotNullOrEmpty;
import static org.fest.util.Strings.quote;

  public static @NotNull PropertyDescriptor getProperty(@NotNull String propertyName, @NotNull Object target) {
    checkNotNullOrEmpty(propertyName);
    checkNotNull(target);
    BeanInfo beanInfo;
    Class<?> type = target.getClass();
    try {
      beanInfo = Introspector.getBeanInfo(type);
    } catch (Throwable t) {
      String msg = String.format("Unable to get BeanInfo for type %s", type.getName());
      throw new IntrospectionError(checkNotNull(msg), t);
    }
    for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) {
      if (propertyName.equals(descriptor.getName())) {
        return descriptor;
      }
    }
    throw propertyNotFoundError(propertyName, target);
  }

  private static @NotNull IntrospectionError propertyNotFoundError(@NotNull String propertyName,
                                                                   @NotNull Object target) {
    Method getter = findGetter(propertyName, target);
    String format;
    if (getter == null) {
      format = "No getter for property %s in %s";
    } else if (!isPublic(getter.getModifiers())) {
      format = "No public getter for property %s in %s";
    } else {
      format = "Unable to find property %s in %s";
    }
    String msg = String.format(format, quote(propertyName), target.getClass().getName());