Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi compile java9 #119

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions jOOR/src/main/java/org/joor/CompilationUnit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* 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 org.joor;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
* Unit for holding multiple source files to be compiled in one go.
*/
public class CompilationUnit {

private final Map<String, String> files = new LinkedHashMap<>();

/**
* The result of the compilation that holds mapping for each className -> class.
*/
public static class Result {
private final Map<String, Class<?>> classes = new LinkedHashMap<>();

void addResult(String className, Class<?> clazz) {
classes.put(className, clazz);
}

/**
* Gets the compiled class by its class name
*
* @param className the class name
* @return the compiled class
*/
public Class<?> getClass(String className) {
return classes.get(className);
}

/**
* Number of classes in the result
*/
public int size() {
return classes.size();
}

/**
* Set of the classes by their names
*/
public Set<String> getClassNames() {
return classes.keySet();
}

}

static CompilationUnit.Result result() {
return new Result();
}

/**
* Creates a new compilation unit for holding input files.
*/
public static CompilationUnit input() {
return new CompilationUnit();
}

/**
* Adds input to the compilation unit.
*
* @param className the class name
* @param content the source code for the class
*/
public CompilationUnit addClass(String className, String content) {
files.put(className, content);
return this;
}

Map<String, String> getInput() {
return files;
}
}
Loading