com.gs.fw.common.mithra.attribute.TupleAttributeImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reladomo Show documentation
Show all versions of reladomo Show documentation
Reladomo is an object-relational mapping framework.
/*
Copyright 2016 Goldman Sachs.
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 com.gs.fw.common.mithra.attribute;
import java.util.*;
import com.gs.fw.common.mithra.*;
import com.gs.fw.common.mithra.extractor.*;
import com.gs.fw.common.mithra.finder.*;
import com.gs.fw.common.mithra.util.*;
public class TupleAttributeImpl implements TupleAttribute
{
private Attribute[] attributes;
public TupleAttributeImpl(Attribute... attributes)
{
this.attributes = Arrays.copyOf(attributes, attributes.length);
}
public TupleAttributeImpl(Attribute first, Attribute second)
{
this.attributes = new Attribute[2];
this.attributes[0] = first;
this.attributes[1] = second;
}
protected TupleAttributeImpl(TupleAttributeImpl tuple, Attribute attr)
{
this.attributes = new Attribute[tuple.attributes.length+1];
System.arraycopy(tuple.attributes, 0, this.attributes, 0, tuple.attributes.length);
this.attributes[tuple.attributes.length] = attr;
}
protected TupleAttributeImpl(Attribute attr, TupleAttributeImpl tuple)
{
this.attributes = new Attribute[tuple.attributes.length+1];
this.attributes[0] = attr;
System.arraycopy(tuple.attributes, 0, this.attributes, 1, tuple.attributes.length);
}
protected TupleAttributeImpl(Attribute attr, Attribute... attributes)
{
this.attributes = new Attribute[attributes.length+1];
this.attributes[0] = attr;
System.arraycopy(attributes, 0, this.attributes, 1, attributes.length);
}
protected TupleAttributeImpl(TupleAttributeImpl first, TupleAttributeImpl second)
{
this.attributes = new Attribute[first.attributes.length+second.attributes.length];
System.arraycopy(first.attributes, 0, this.attributes, 0, first.attributes.length);
System.arraycopy(second.attributes, 0, this.attributes, first.attributes.length, second.attributes.length);
}
public TupleAttributeImpl(TupleAttributeImpl first, Attribute[] attributes)
{
this.attributes = new Attribute[first.attributes.length+attributes.length];
System.arraycopy(first.attributes, 0, this.attributes, 0, first.attributes.length);
System.arraycopy(attributes, 0, this.attributes, first.attributes.length, attributes.length);
}
public TupleAttribute tupleWith(Attribute attr)
{
return new TupleAttributeImpl(this, attr);
}
public TupleAttribute tupleWith(TupleAttribute attr)
{
return new TupleAttributeImpl(this, (TupleAttributeImpl) attr);
}
public TupleAttribute tupleWith(Attribute... attr)
{
return new TupleAttributeImpl(this, attr);
}
public Operation in(TupleSet tupleSet)
{
if (tupleSet.size() == 0)
{
return new None(this.attributes[0]);
}
return new MultiInOperation(this.attributes, (MithraTupleSet) tupleSet);
}
public Operation in(List dataHolders, Extractor[] extractors)
{
if (dataHolders.size() == 0)
{
return new None(this.attributes[0]);
}
for(int i=0;i 0 && i 0)
{
Operation inOperation = NoOperation.instance();
Operation constantOp = NoOperation.instance();
int leftOver = extractors.length - constantCount;
if (leftOver == 0)
{
for(int j=0;j