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

com.google.security.fences.config.NamedLeafFence Maven / Gradle / Ivy

There is a newer version: 1.9-beta
Show newest version
package com.google.security.fences.config;

import com.google.common.collect.ImmutableList;

abstract class NamedLeafFence extends NamedFence {
  @Override
  public Iterable getChildFences() {
    return ImmutableList.of();
  }

  protected abstract void addToClass(ClassFence container);

  @Override
  public Fence splitDottedNames() {
    String name = getName();
    String[] parts = name.split("[.]");
    if (parts.length == 1) {
      return this;
    }

    int i = parts.length - 1;
    this.setName(parts[i]);
    String className = parts[--i];
    ClassFence c = new ClassFence();
    c.setName(className);
    addToClass(c);

    Fence f = c;
    while (--i >= 0) {
      String part = parts[i];
      PackageFence pkg = new PackageFence();
      pkg.setName(part);
      if (f instanceof ClassFence) {
        pkg.setClass((ClassFence) f);
      } else {
        pkg.setPackage((PackageFence) f);
      }
      f = pkg;
    }
    return f;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy