diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/solutionstore/IdBasedSolutionNameProvider.java')
-rw-r--r-- | Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/solutionstore/IdBasedSolutionNameProvider.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/solutionstore/IdBasedSolutionNameProvider.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/solutionstore/IdBasedSolutionNameProvider.java new file mode 100644 index 00000000..43460015 --- /dev/null +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/solutionstore/IdBasedSolutionNameProvider.java | |||
@@ -0,0 +1,37 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2017, Andras Szabolcs Nagy and Daniel Varro | ||
3 | * This program and the accompanying materials are made available under the | ||
4 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
5 | * http://www.eclipse.org/legal/epl-v20.html. | ||
6 | * | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | package org.eclipse.viatra.dse.solutionstore; | ||
10 | |||
11 | /** | ||
12 | * Provides file name with a String <code>[prefix][id].[extension]</code> pattern. | ||
13 | * @author Andras Szabolcs Nagy | ||
14 | * | ||
15 | */ | ||
16 | public class IdBasedSolutionNameProvider implements ISolutionNameProvider { | ||
17 | |||
18 | private int id = 1; | ||
19 | private String prefix; | ||
20 | private String extension; | ||
21 | |||
22 | public IdBasedSolutionNameProvider(String prefix, String extension) { | ||
23 | this.extension = extension; | ||
24 | this.prefix = prefix; | ||
25 | |||
26 | } | ||
27 | |||
28 | @Override | ||
29 | public String getName() { | ||
30 | StringBuilder sb = new StringBuilder(prefix); | ||
31 | sb.append(id++); | ||
32 | sb.append('.'); | ||
33 | sb.append(extension); | ||
34 | return sb.toString(); | ||
35 | } | ||
36 | |||
37 | } \ No newline at end of file | ||