-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6560: handling combination of code and magic, correct results
- Loading branch information
1 parent
8e6237a
commit 558a0ce
Showing
77 changed files
with
898 additions
and
1,062 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
97 changes: 97 additions & 0 deletions
97
kernel/base/src/main/java/com/twosigma/beakerx/TryResult.java
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,97 @@ | ||
/* | ||
* Copyright 2018 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* 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.twosigma.beakerx; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
public interface TryResult { | ||
|
||
boolean isResult(); | ||
|
||
boolean isError(); | ||
|
||
Object result(); | ||
|
||
String error(); | ||
|
||
static CellResult createResult(Object value) { | ||
return new TryResult.CellResult(value); | ||
} | ||
|
||
static CellError createError(String value) { | ||
return new TryResult.CellError(value); | ||
} | ||
|
||
|
||
final class CellResult implements TryResult { | ||
|
||
private final Object value; | ||
|
||
private CellResult(Object value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public boolean isResult() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isError() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Object result() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String error() { | ||
throw new NoSuchElementException("error() on CellResult"); | ||
} | ||
} | ||
|
||
final class CellError implements TryResult { | ||
|
||
private final String value; | ||
|
||
private CellError(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public boolean isResult() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isError() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public Object result() { | ||
throw new NoSuchElementException("result() on CellError"); | ||
} | ||
|
||
@Override | ||
public String error() { | ||
return value; | ||
} | ||
} | ||
|
||
} |
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
59 changes: 0 additions & 59 deletions
59
...el/base/src/main/java/com/twosigma/beakerx/jvm/object/SimpleEvaluationObjectWithTime.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.