|
| 1 | +/****************************** |
| 2 | +* Copyright (c) 2003--2024 Kevin Lano |
| 3 | +* This program and the accompanying materials are made available under the |
| 4 | +* terms of the Eclipse Public License 2.0 which is available at |
| 5 | +* http://www.eclipse.org/legal/epl-2.0 |
| 6 | +* |
| 7 | +* SPDX-License-Identifier: EPL-2.0 |
| 8 | +* *****************************/ |
| 9 | +/* package: TransformationSynthesis */ |
| 10 | + |
| 11 | + |
| 12 | +public class ValueMatching |
| 13 | +{ Expression src; |
| 14 | + Expression trg; |
| 15 | + |
| 16 | + public ValueMatching(Expression s, Expression t) |
| 17 | + { src = s; |
| 18 | + trg = t; |
| 19 | + } |
| 20 | + |
| 21 | + public ValueMatching(String s, String t) |
| 22 | + { src = new BasicExpression(s); |
| 23 | + trg = new BasicExpression(t); |
| 24 | + } |
| 25 | + |
| 26 | + public String toString() |
| 27 | + { return src + " |--> " + trg; } |
| 28 | + |
| 29 | + public boolean isIdentityMapping() |
| 30 | + { String ss = (src + "").trim(); |
| 31 | + String tt = (trg + "").trim(); |
| 32 | + if ("_1".equals(ss) && "_1".equals(tt)) |
| 33 | + { return true; } |
| 34 | + if ("_0".equals(ss) && "_0".equals(tt)) |
| 35 | + { return true; } |
| 36 | + if (ss.startsWith("\"") && ss.endsWith("\"") && |
| 37 | + tt.startsWith("\"") && tt.endsWith("\"") && |
| 38 | + ss.substring(1,ss.length()-1).trim().equals( |
| 39 | + tt.substring(1,tt.length()-1).trim())) |
| 40 | + { System.out.println(">>> Identity mapping: " + ss + " |--> " + tt); |
| 41 | + return true; |
| 42 | + } |
| 43 | + return false; |
| 44 | + } |
| 45 | + |
| 46 | + public ValueMatching invert() |
| 47 | + { return new ValueMatching(trg,src); } |
| 48 | + |
| 49 | + public boolean equals(Object obj) |
| 50 | + { if (obj instanceof ValueMatching) |
| 51 | + { ValueMatching vm = (ValueMatching) obj; |
| 52 | + if (src.equals(vm.src) && trg.equals(vm.trg)) |
| 53 | + { return true; } |
| 54 | + } |
| 55 | + return false; |
| 56 | + } |
| 57 | +} |
0 commit comments