org.apache.commons.weaver.model.NestedWeavable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-weaver-processor Show documentation
Show all versions of commons-weaver-processor Show documentation
Defines the Apache Commons Weaver SPI as well as the basic build-time
(filesystem-based) processors that detect, configure, and invoke
available modules.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.commons.weaver.model;
/**
* Describes a {@link Weavable} that lives inside some other {@link Weavable}.
* @param own type
* @param weavable target type
* @param enclosing weavable type
* @param parent target type
*/
public abstract class NestedWeavable
,
TARGET,
PARENT extends Weavable,
PARENT_TARGET>
extends Weavable {
private final PARENT parent;
/**
* Create a new {@link NestedWeavable} instance.
* @param target element
* @param parent enclosing
*/
protected NestedWeavable(final TARGET target, final PARENT parent) {
super(target);
this.parent = parent;
}
/**
* Get the parent.
* @return {@code PARENT}
*/
public PARENT getParent() {
return parent;
}
/**
* Implement {@link Comparable}.
* @param obj {@code SELF}
* @return int per {@link Comparable#compareTo(Object)} contract
*/
@Override
public final int compareTo(final SELF obj) {
final int result = getParent().compareTo(obj.getParent());
return result == 0 ? localCompareTo(obj) : result;
}
/**
* Compare against {@code o} without respect to {@link #getParent()}.
* @param obj SELF{@code SELF}
* @return int per {@link Comparable#compareTo(Object)} contract
*/
protected abstract int localCompareTo(SELF obj);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy