Checks whether the given package must be exported. The decision is made from heuristics.

@param packageName the package name
@return {@literal true} if the package has to be exported, {@literal false} otherwise.
423924
public static boolean shouldBeExported(String packageName) {
        boolean service = packageName.endsWith(".service");
        service = service
                || packageName.contains(".service.")
                || packageName.endsWith(".services")
                || packageName.contains(".services.");

        boolean api = packageName.endsWith(".api");
        api = api
                || packageName.contains(".api.")
                || packageName.endsWith(".apis")
                || packageName.contains(".apis.");

        boolean model = packageName.endsWith(".model");
        model = model
                || packageName.contains(".model.")
                || packageName.endsWith(".models")
                || packageName.contains(".models.");

        boolean entity = packageName.endsWith(".entity");
        entity = entity
                || packageName.contains(".entity.")
                || packageName.endsWith(".entities")
                || packageName.contains(".entities.");

        return !packageName.isEmpty() && !packageName.equals(".") && (service || api || model || entity);
    }
1032486
public boolean packageExists(ModuleSymbol msym, Name fullname) {
        Assert.checkNonNull(msym);
        return lookupPackage(msym, fullname).exists();
    }
674139
public static RefactoringStatus validatePackageName(String newName) {
		if (!PACKAGE_NAME_PATTERN.matcher(newName).find()) {
			RefactoringStatus.createErrorStatus(MessageFormat.format(Messages.SARLJdtPackageRenameParticipant_0, newName));
		}
		return new RefactoringStatus();
	}
1205306
public boolean isExternal(ProgramElementDoc doc) {
        if (packageToItemMap == null) {
            return false;
        }
        return packageToItemMap.get(doc.containingPackage().name()) != null;
    }
1077048
function isValidPackageName(name) {
  const stats = validateName(name);
  return stats.validForNewPackages === true
    && stats.validForOldPackages === true;
}
303411
public boolean isJDKInternalPackage(Module module, String pn) {
        if (module.isJDKUnsupported()) {
            // its exported APIs are unsupported
            return true;
        }

        return module.isJDK() && !module.isExported(pn);
    }
854169
public static boolean isPackageInstaller(@NotNull final Context context, final String packageName) {
        final PackageManager packageManager = context.getPackageManager();
        final String installerPackageName = packageManager.getInstallerPackageName(context.getPackageName());
        boolean isPackageInstaller = TextUtils.equals(installerPackageName, packageName);
        Logger.d("isPackageInstaller() is ", isPackageInstaller, " for ", packageName);
        return isPackageInstaller;
    }
185205
private static BundleCapability getExportedPackage(BundleContext context, String packageName) {
        List<BundleCapability> packages = new ArrayList<BundleCapability>();
        for (Bundle bundle : context.getBundles()) {
            BundleRevision bundleRevision = bundle.adapt(BundleRevision.class);
            for (BundleCapability packageCapability : bundleRevision.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE)) {
                String pName = (String) packageCapability.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE);
                if (pName.equalsIgnoreCase(packageName)) {
                    packages.add(packageCapability);
                }
            }
        }

        Version max = Version.emptyVersion;
        BundleCapability maxVersion = null;
        for (BundleCapability aPackage : packages) {
            Version version = (Version) aPackage.getAttributes().get("version");
            if (max.compareTo(version) <= 0) {
                max = version;
                maxVersion = aPackage;
            }
        }

        return maxVersion;
    }
595883
function (packageName) {
    let result;

    try {
      result = require.resolve(packageName, { basedir: process.cwd() });
      result = require(result);
    } catch (e) {
      try {
        result = require(packageName);
      } catch (e) {
        result = undefined;
      }
    }

    return result;
  }
1183863
private boolean hasPrintedPackageIndex(String pkgname) {
        String[] list = printedPackageHeaders.toArray(new String[] {});
        for (String packageHeader : list) {
            if (pkgname.startsWith(packageHeader)) {
                return true;
            }
        }
        return false;
    }
381724
protected function existsPackageName($packageName)
    {
        if (!$packageName || !$this->isPackageName($packageName)) {
            return false;
        }

        $exists = shell_exec('composer search --only-name '.$packageName);

        return (bool) $exists;
    }
825123
public void getExportedPackages(Set<String> exportedPackages) {
		if (exportedPackages != null) {
			exportedPackages.add(getCodeElementExtractor().getBasePackage());
			exportedPackages.add(getCodeElementExtractor().getBuilderPackage());
			if (getCodeBuilderConfig().isISourceAppendableEnable()) {
				exportedPackages.add(getCodeElementExtractor().getAppenderPackage());
			}
		}
	}
285083
static boolean isPackageInstalled(Context context) {
        boolean isInstalled = false;
        if (context != null) {
            try {
                final PackageManager packageManager = context.getPackageManager();
                Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
                if (intent == null) {
                    return false;
                }
                List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);

                isInstalled = (list != null && list.size() > 0);
            } catch (Exception e) {
                PrefHelper.LogException("Error obtaining PackageInfo", e);
            }
        }

        return isInstalled;
    }
798782
public function hasInstalledPackage($packageName)
    {
        foreach ($this->contents['packages'] as $packageDetails) {
            if ($packageName === $packageDetails['name']) {
                return true;
            }
        }
        
        return false;
    }
317999
public void addPackage(String packageName) throws IOException {
    if (this.packagePrefix != null) {
      throw new IllegalStateException();
    }
    out.write("package ");
    out.write(packageName);
    out.write(";\n");
    this.packagePrefix = packageName + ".";
  }
631719
public boolean isImportingWicket() {
        BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
        // First check if there is a wiring to any package of org.apache.wicket
        List<BundleWire> importPackageWires = bundleWiring.getRequiredWires(OSGI_WIRING_PACKAGE_NAMESPACE);
        for (BundleWire bundleWire : importPackageWires) {
            BundleRequirement requirement = bundleWire.getRequirement();
            String filter = requirement.getDirectives().get(FILTER_DIRECTIVE);
            if (filter != null) {
                Matcher matcher = PACKAGE_PATTERN_WICKET.matcher(filter);
                if (matcher.find()) {
                    return true;
                }
            }
        }
        List<BundleWire> requireBundleWires = bundleWiring.getRequiredWires(OSGI_WIRING_BUNDLE_NAMESPACE);
        if (!requireBundleWires.isEmpty()) {
            // find all apache.wicket bundles and check if there are wirings...
            Bundle[] bundles = bundleContext.paxBundleContext.getBundles();
            for (Bundle bundle : bundles) {
                String symbolicName = bundle.getSymbolicName();
                if (symbolicName.startsWith(APACHE_WICKET_NAMESPACE)) {
                    Map<String, Object> map = createMapWithVersion(OSGI_WIRING_BUNDLE_NAMESPACE, symbolicName,
                        bundle.getVersion());
                    if (hasWireMatchingFilter(requireBundleWires, map)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
1058880
public static boolean ensureSameSignature(Context context, String targetPackageName) {
        return ensureSameSignature(context, targetPackageName, getSignatureHexCode(context));
    }