|
Java example source code file (HierarchyGenerator.java)
The HierarchyGenerator.java Java example source code/* * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.tests.shapegen; import org.openjdk.tests.shapegen.ClassCase.Kind; import java.util.Collection; import java.util.Set; import java.util.HashSet; import java.util.Collections; import java.util.ArrayList; import java.util.List; import static org.openjdk.tests.shapegen.ClassCase.Kind.*; import static java.lang.Math.pow; /** * * @author Robert Field */ public final class HierarchyGenerator { private int okcnt = 0; private int errcnt = 0; private Set<Hierarchy> uniqueOK = new HashSet<>(); private Set<Hierarchy> uniqueErr = new HashSet<>(); /** * @param args the command line arguments */ public HierarchyGenerator() { organize("exhaustive interface", iExhaustive(2)); organize("exhaustive class", cExhaustive()); organize("shapes interface", iShapes()); organize("shapes class/interface", ciShapes()); System.out.printf("\nExpect OK: %d -- unique %d", okcnt, uniqueOK.size()); System.out.printf("\nExpect Error: %d -- unique %d\n", errcnt, uniqueErr.size()); } public Collection<Hierarchy> getOK() { return uniqueOK; } public Collection<Hierarchy> getErr() { return uniqueErr; } private void organize(String tname, List<Hierarchy> totest) { System.out.printf("\nGenerating %s....\n", tname); int nodefault = 0; List<Hierarchy> ok = new ArrayList<>(); List<Hierarchy> err = new ArrayList<>(); for (Hierarchy cc : totest) { if (cc.anyDefaults()) { //System.out.printf(" %s\n", cc); if (cc.get_OK()) { ok.add(cc); } else { err.add(cc); } } else { ++nodefault; } } errcnt += err.size(); okcnt += ok.size(); uniqueErr.addAll(err); uniqueOK.addAll(ok); System.out.printf(" %5d No default\n %5d Error\n %5d OK\n %5d Total\n", nodefault, err.size(), ok.size(), totest.size()); } public List<Hierarchy> iExhaustive(int idepth) { List<ClassCase> current = new ArrayList<>(); for (int i = 0; i < idepth; ++i) { current = ilayer(current); } return wrapInClassAndHierarchy(current); } private List<ClassCase> ilayer(List Other Java examples (source code examples)Here is a short list of links related to this Java HierarchyGenerator.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.