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

org.omnifaces.persistence.service.JoinFetchAdapter Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2021 OmniFaces
 *
 * 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
 *
 *     https://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.omnifaces.persistence.service;

import java.util.Set;

import jakarta.persistence.criteria.Fetch;
import jakarta.persistence.criteria.FetchParent;
import jakarta.persistence.criteria.Join;
import jakarta.persistence.criteria.JoinType;
import jakarta.persistence.metamodel.Attribute;
import jakarta.persistence.metamodel.PluralAttribute;
import jakarta.persistence.metamodel.SingularAttribute;

/**
 * This class adapts from {@link Join} to {@link Fetch}.
 * @see SubqueryRoot
 */
class JoinFetchAdapter implements Fetch {

	private Join join;

	public JoinFetchAdapter(Join join) {
		this.join = join;
	}

	@Override
	public Attribute getAttribute() {
		return join.getAttribute();
	}

	@Override
	public FetchParent getParent() {
		return join.getParent();
	}

	@Override
	public JoinType getJoinType() {
		return join.getJoinType();
	}

	@Override
	public Set> getFetches() {
		return join.getFetches();
	}

	@Override
	public  Fetch fetch(SingularAttribute attribute) {
		return new JoinFetchAdapter<>(join.join(attribute));
	}

	@Override
	public  Fetch fetch(SingularAttribute attribute, JoinType jt) {
		return new JoinFetchAdapter<>(join.join(attribute, jt));
	}

	@Override
	public  Fetch fetch(PluralAttribute attribute) {
		throw new UnsupportedOperationException();
	}

	@Override
	public  Fetch fetch(PluralAttribute attribute, JoinType jt) {
		throw new UnsupportedOperationException();
	}

	@Override
	@SuppressWarnings("hiding")
	public  Fetch fetch(String attributeName) {
		return new JoinFetchAdapter<>(join.join(attributeName));
	}

	@Override
	@SuppressWarnings("hiding")
	public  Fetch fetch(String attributeName, JoinType jt) {
		return new JoinFetchAdapter<>(join.join(attributeName, jt));
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy