-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redesign lambdas and projections handling
Fixes #5: validate lambda expression upon construction
- Loading branch information
1 parent
f6d5a00
commit 115cae4
Showing
12 changed files
with
375 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright (c) 2011-2014 Exxeleron GmbH | ||
* | ||
* 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.exxeleron.qjava; | ||
|
||
/** | ||
* Represents q function. | ||
* | ||
* Note that the {@link QFunction} instances cannot be serialized to IPC protocol. | ||
*/ | ||
public class QFunction { | ||
|
||
private final byte qTypeCode; | ||
|
||
/** | ||
* Creates representation of q function with given q type code. | ||
* | ||
* @param qTypeCode | ||
* q type code | ||
*/ | ||
protected QFunction(final byte qTypeCode) { | ||
this.qTypeCode = qTypeCode; | ||
} | ||
|
||
/** | ||
* Retrieve q type code connected with function. | ||
* | ||
* @return type code for function | ||
*/ | ||
public byte getTypeCode() { | ||
return qTypeCode; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "QFunction#" + qTypeCode + "h"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Copyright (c) 2011-2014 Exxeleron GmbH | ||
* | ||
* 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.exxeleron.qjava; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* Represents a q projection. | ||
*/ | ||
public final class QProjection extends QFunction{ | ||
private final Object[] parameters; | ||
|
||
/** | ||
* Gets parameters of a q projection. | ||
* | ||
* @return array containing projection parameters | ||
*/ | ||
public Object[] getParameters() { | ||
return parameters; | ||
} | ||
|
||
/** | ||
* Creates new {@link QProjection} instance with given parameters. | ||
* | ||
* @param parameters | ||
* array containing projection parameters | ||
* | ||
* @throws IllegalArgumentException | ||
*/ | ||
public QProjection(final Object[] parameters) { | ||
super(QType.PROJECTION.getTypeCode()); | ||
this.parameters = parameters; | ||
} | ||
|
||
/** | ||
* Returns a String that represents the current {@link QProjection}. | ||
* | ||
* @return a String representation of the {@link QProjection} | ||
* @see java.lang.Object#toString() | ||
*/ | ||
@Override | ||
public String toString() { | ||
return "QProjection: " + (parameters == null ? "<null>" : Utils.arrayToString(parameters)); | ||
} | ||
|
||
/** | ||
* Indicates whether some other object is "equal to" this projection. {@link QProjection} objects are considered | ||
* equal if the parameters list are equal for both instances. | ||
* | ||
* @return <code>true</code> if this object is the same as the obj argument, <code>false</code> otherwise. | ||
* @see java.lang.Object#equals(java.lang.Object) | ||
*/ | ||
@Override | ||
public boolean equals( final Object obj ) { | ||
if ( this == obj ) { | ||
return true; | ||
} | ||
|
||
if ( !(obj instanceof QProjection) ) { | ||
return false; | ||
} | ||
|
||
final QProjection p = (QProjection) obj; | ||
return Utils.deepArraysEquals(parameters, p.parameters); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Arrays.hashCode(parameters); | ||
} | ||
|
||
} |
Oops, something went wrong.