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

br.com.objectos.css.io.SimplePseudoClassSelector Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2016 Objectos, Fábrica de Software LTDA.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package br.com.objectos.css.io;

import java.util.EnumSet;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import br.com.objectos.css.Selectable;

/**
 * @author [email protected] (Marcio Endo)
 */
enum SimplePseudoClassSelector implements PseudoClassSelector {

  // 6.6.1.1. The link pseudo-classes
  LINK,
  VISITED,

  // 6.6.1.2. The user action pseudo-classes
  HOVER,
  ACTIVE,
  FOCUS,

  // 6.6.2. The target pseudo-class
  TARGET,

  // 6.6.3. The language pseudo-class
  // LANG,

  // 6.6.4.1. The :enabled and :disabled pseudo-classes
  ENABLED,
  DISABLED,

  // 6.6.4.2. The :checked pseudo-class
  CHECKED,

  // 6.6.4.3. The :indeterminate pseudo-class
  INDETERMINATE,

  // 6.6.5.1. :root pseudo-class
  // 6.6.5.2. :nth-child() pseudo-class
  // 6.6.5.3. :nth-last-child() pseudo-class
  // 6.6.5.4. :nth-of-type() pseudo-class
  // 6.6.5.5. :nth-last-of-type() pseudo-class
  // 6.6.5.6. :first-child pseudo-class
  FIRST_CHILD,

  // 6.6.5.7. :last-child pseudo-class
  // 6.6.5.8. :first-of-type pseudo-class
  // 6.6.5.9. :last-of-type pseudo-class
  // 6.6.5.10. :only-child pseudo-class
  // 6.6.5.11. :only-of-type pseudo-class
  // 6.6.5.12. :empty pseudo-class
  EMPTY;

  private final String value;

  private SimplePseudoClassSelector() {
    value = ":" + name().replace('_', '-').toLowerCase();
  }

  private static final Map MAP = EnumSet.allOf(SimplePseudoClassSelector.class)
      .stream()
      .collect(Collectors.toMap(e -> e.name().replace('_', '-').toLowerCase(), Function.identity()));

  public static SimplePseudoClassSelector parse(String stateName) {
    return MAP.get(stateName);
  }

  @Override
  public boolean matches(Selectable element) {
    return false;
  }

  @Override
  public String toString() {
    return value;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy