|  | 
|  | 1 | +/* | 
|  | 2 | + * Copyright 2025 the original author or authors. | 
|  | 3 | + * | 
|  | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | + * you may not use this file except in compliance with the License. | 
|  | 6 | + * You may obtain a copy of the License at | 
|  | 7 | + * | 
|  | 8 | + *      https://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | + * | 
|  | 10 | + * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | + * See the License for the specific language governing permissions and | 
|  | 14 | + * limitations under the License. | 
|  | 15 | + */ | 
|  | 16 | +package org.springframework.data.mapping; | 
|  | 17 | + | 
|  | 18 | +import java.util.Iterator; | 
|  | 19 | +import java.util.List; | 
|  | 20 | + | 
|  | 21 | +import org.springframework.data.util.TypeInformation; | 
|  | 22 | + | 
|  | 23 | +record ComposedPropertyPath<T, M, R>(TypedPropertyPath<T, M> first, | 
|  | 24 | +		TypedPropertyPath<M, R> second) implements TypedPropertyPath<T, R> { | 
|  | 25 | + | 
|  | 26 | +	@Override | 
|  | 27 | +	public R get(T obj) { | 
|  | 28 | +		M intermediate = first.get(obj); | 
|  | 29 | +		return intermediate != null ? second.get(intermediate) : null; | 
|  | 30 | +	} | 
|  | 31 | + | 
|  | 32 | +	@Override | 
|  | 33 | +	public TypeInformation<?> getOwningType() { | 
|  | 34 | +		return first.getOwningType(); | 
|  | 35 | +	} | 
|  | 36 | + | 
|  | 37 | +	@Override | 
|  | 38 | +	public String getSegment() { | 
|  | 39 | +		return first().getSegment(); | 
|  | 40 | +	} | 
|  | 41 | + | 
|  | 42 | +	@Override | 
|  | 43 | +	public PropertyPath getLeafProperty() { | 
|  | 44 | +		return second.getLeafProperty(); | 
|  | 45 | +	} | 
|  | 46 | + | 
|  | 47 | +	@Override | 
|  | 48 | +	public TypeInformation<?> getTypeInformation() { | 
|  | 49 | +		return first.getTypeInformation(); | 
|  | 50 | +	} | 
|  | 51 | + | 
|  | 52 | +	@Override | 
|  | 53 | +	public PropertyPath next() { | 
|  | 54 | +		return second; | 
|  | 55 | +	} | 
|  | 56 | + | 
|  | 57 | +	@Override | 
|  | 58 | +	public boolean hasNext() { | 
|  | 59 | +		return true; | 
|  | 60 | +	} | 
|  | 61 | + | 
|  | 62 | +	@Override | 
|  | 63 | +	public String toDotPath() { | 
|  | 64 | +		return first.toDotPath() + "." + second.toDotPath(); | 
|  | 65 | +	} | 
|  | 66 | + | 
|  | 67 | +	@Override | 
|  | 68 | +	public Iterator<PropertyPath> iterator() { | 
|  | 69 | +		return List.<PropertyPath> of(this, second).iterator(); | 
|  | 70 | +	} | 
|  | 71 | + | 
|  | 72 | +} | 
0 commit comments