Java Code Examples for org.openide.util.BaseUtilities#compareObjects()

The following examples show how to use org.openide.util.BaseUtilities#compareObjects() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocaleVariants.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Similar to {@link NbBundle#getLocalizingSuffixes} but optimized.
 * @since JST-PENDING: Called from InstalledFileLocatorImpl
 */
static synchronized String[] getLocalizingSuffixesFast() {
    if (suffixes == null ||
            Locale.getDefault() != lastLocale ||
            !BaseUtilities.compareObjects(NbBundle.getBranding(), lastBranding)) {
        List<String> _suffixes = new ArrayList<String>();
        Iterator<String> it = NbBundle.getLocalizingSuffixes();
        while (it.hasNext()) {
            _suffixes.add(it.next());
        }
        suffixes = _suffixes.toArray(new String[_suffixes.size()]);
        lastLocale = Locale.getDefault();
        lastBranding = NbBundle.getBranding();
    }
    return suffixes;
}
 
Example 2
Source File: LibrariesSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Sets {@link LibraryImplementation} {@link URI} content.
 * @param impl the {@link LibraryImplementation} to set the {@link URI} content to
 * @param volumeType the volumeType
 * @param path the {@link URI} content
 * @param conversionMode conversion failure policy in case the library does not
 * support {@link URI} content and the path {@link URI}s are converted to {@link URL}s
 * @return true if given {@link LibraryImplementation} support {@link URI} content
 * @throws IllegalArgumentException when unsupported volumeType or for unconvertable entry in
 * {@link ConversionMode#FAIL}
 * @since 1.48
 */
public static boolean setURIContent(
    @NonNull final LibraryImplementation impl,
    @NonNull final String volumeType,
    @NonNull final List<URI> path,
    @NonNull final ConversionMode conversionMode) {
    if (supportsURIContent(impl)) {
        final LibraryImplementation2 impl2 = (LibraryImplementation2)impl;
        if (!BaseUtilities.compareObjects(impl2.getURIContent(volumeType), path)) {
            impl2.setURIContent(volumeType, path);
            return true;
        }
    } else {
        impl.setContent(
            volumeType,
            convertURIsToURLs(
                path,
                conversionMode));
        return true;
    }
    return false;
}
 
Example 3
Source File: ProjectLibraryProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void setDisplayName(final @NullAllowed String displayName) {
    if (BaseUtilities.compareObjects(this.displayName, displayName)) {
        return;
    }
    final String oldDisplayName = this.displayName;
    this.displayName = displayName;
    try {
        final String key = String.format("libs.%s.%s",name, SFX_DISPLAY_NAME);  //NOI18N
        replaceProperty(
            mainPropertiesFile,
            false,
            key,
            displayName == null ? new String[0] : new String[]{displayName});
    } catch (IOException x) {
        throw new IllegalArgumentException(x);
    }
    pcs.firePropertyChange(PROP_DISPLAY_NAME, oldDisplayName, displayName);
}
 
Example 4
Source File: ProjectLibraryProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void setProperties(Map<String, String> properties) {
    if (BaseUtilities.compareObjects(this.properties, properties)) {
        return;
    }
    final Map<String,String> oldProperties = this.properties;
    this.properties = new HashMap<String, String>(properties);
    try {
        for (Map.Entry<String,String> e : this.properties.entrySet()) {
            final String key = String.format(
                "libs.%s.%s%s",    //NOI18N
                name,
                PROP_PREFIX,
                e.getKey());
            replaceProperty(
                mainPropertiesFile,
                false,
                key,
                e.getValue());
        }
    } catch (IOException x) {
        throw new IllegalArgumentException(x);
    }
    pcs.firePropertyChange(PROP_PROPERTIES, oldProperties, this.properties);
}
 
Example 5
Source File: ProjectProperties.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Sets EditableProperties.
 * @param nue the new {@link EditableProperties}
 * @return true if changed
 * Threading: called under exclusive lock
 */
public boolean put(EditableProperties nue) {
    loaded = true;
    reloadedStackTrace = null;
    filePropertiesChanged = filePropertiesChanged ||
        !Objects.equals(nue, cachedPropertiesFromFile);
    boolean modifying = !BaseUtilities.compareObjects(nue, properties);
    if (modifying) {
        if (nue != null) {
            properties = nue.cloneProperties();
        } else {
            properties = null;
        }
        fireChange();
    }
    return modifying;
}
 
Example 6
Source File: TypedValue.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public @Override boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final TypedValue other = (TypedValue) obj;
    if (!BaseUtilities.compareObjects(this.value, other.value)) {
        return false;
    }
    if (!BaseUtilities.compareObjects(this.javaType, other.javaType)) {
        return false;
    }
    return true;
}
 
Example 7
Source File: ChangeFirer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public boolean equals(Object o) {
    if (! (o instanceof Change)) return false;
    Change c = (Change) o;
    return BaseUtilities.compareObjects(prop, c.prop) &&
           BaseUtilities.compareObjects(source, c.source) &&
           BaseUtilities.compareObjects(old, c.old) &&
           BaseUtilities.compareObjects(nue, c.nue);
}
 
Example 8
Source File: Dependency.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Overridden to compare contents. */
@Override
public boolean equals(Object o) {
    if (o.getClass() != Dependency.class) {
        return false;
    }

    Dependency d = (Dependency) o;

    return (type == d.type) && (comparison == d.comparison) && name.equals(d.name) &&
    BaseUtilities.compareObjects(version, d.version);
}
 
Example 9
Source File: LibrariesSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Sets {@link LibraryImplementation} display name.
 * @param impl the {@link LibraryImplementation} to set the display name to
 * @param name the display name
 * @return true if given {@link LibraryImplementation} support display name
 * @since 1.48
 */
public static boolean setDisplayName(
        final @NonNull LibraryImplementation impl,
        final @NullAllowed String name) {
    if (supportsDisplayName(impl)) {
        final NamedLibraryImplementation nimpl = (NamedLibraryImplementation) impl;
        if (!BaseUtilities.compareObjects(nimpl.getDisplayName(), name)) {
            nimpl.setDisplayName(name);
            return true;
        }
    }
    return false;
}
 
Example 10
Source File: LibrariesSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Sets {@link LibraryImplementation} properties.
 * @param impl the {@link LibraryImplementation} to set properties to
 * @param props the properties
 * @return true if given {@link LibraryImplementation} support properties
 * @since 1.48
 */
public static boolean setProperties(
    final @NonNull LibraryImplementation impl,
    final @NonNull Map<String,String>  props) {
    if (supportsProperties(impl)) {
        final LibraryImplementation3 impl3 = (LibraryImplementation3)impl;
        if (!BaseUtilities.compareObjects(impl3.getProperties(), props)) {
            impl3.setProperties(props);
            return true;
        }
    }
    return false;
}
 
Example 11
Source File: GlobFileBuiltQuery.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void recalcTarget() {
    File target2 = findTarget(source.getFileObject());
    if (!BaseUtilities.compareObjects(target, target2)) {
        synchronized(targetListener) {
            // #45694: source file moved, recalculate target.
            if (target != null) {
                FileUtil.removeFileChangeListener(targetListener, target);
            }
            if (target2 != null) {
                FileUtil.addFileChangeListener(targetListener, target2);
            }
        }
        target = target2;
    }
}
 
Example 12
Source File: LibraryDeclarationHandlerImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void end_library() throws SAXException {
    boolean update;
    if (this.library != null) {
        if (this.libraryType == null || !this.libraryType.equals(this.library.getType())) {
            throw new SAXParseException("Changing library type of library: "+this.libraryName+" from: "+
                    library.getType()+" to: " + libraryType, null); //NOI18N
        }
        update = true;
    } else {
        if (this.libraryType == null) {
            throw new SAXParseException("Unspecified library type for: "+this.libraryName, null); //NOI18N
        }
        LibraryTypeProvider provider = LibraryTypeRegistry.getDefault().getLibraryTypeProvider(this.libraryType);
        if (provider == null) {
            throw new UnknownLibraryTypeException(libraryName, libraryType);
        }
        this.library = provider.createLibrary();
        update = false;
        LibrariesStorage.LOG.log(Level.FINE, "LibraryDeclarationHandlerImpl library {0} type {1} found", new Object[] { this.libraryName, this.libraryType });
    }
    if (!update || !BaseUtilities.compareObjects(this.library.getLocalizingBundle(), localizingBundle)) {
        this.library.setLocalizingBundle (this.localizingBundle);
    }
    if (!update || !BaseUtilities.compareObjects(this.library.getName(), libraryName)) {
        this.library.setName (this.libraryName);
    }
    if (!update || !BaseUtilities.compareObjects(this.library.getDescription(), libraryDescription)) {
        this.library.setDescription (this.libraryDescription);
    }
    LibrariesSupport.setDisplayName(this.library,displayName);
    LibrariesSupport.setProperties(this.library, properties);
    for (Map.Entry<String,List<URL>> entry : contentTypes.entrySet()) {
        String contentType = entry.getKey();
        List<URL> cp = entry.getValue();
        try {
            if (!update || !urlsEqual(this.library.getContent(contentType),cp)) {
                this.library.setContent(contentType, cp);
            }
        } catch (IllegalArgumentException e) {
            throw new SAXException(e);
        }
    }
}