예제 #1
0
            /// <summary>
            /// Sets the flags component of this builder. On return, the flags
            /// component of this builder is a copy of the given set.
            /// </summary>
            /// <param name="flags">  the flags component </param>
            /// <returns>  this builder
            /// </returns>
            /// <exception cref="ClassCastException">
            ///          if the set contains elements that are not of type {@code
            ///          AclEntryFlag} </exception>
            public Builder SetFlags(Set <AclEntryFlag> flags)
            {
                if (flags.Count == 0)
                {
                    // EnumSet.copyOf does not allow empty set
                    flags = java.util.Collections.EmptySet();
                }
                else
                {
                    // copy and check for erroneous elements
                    flags = EnumSet.CopyOf(flags);
                    CheckSet(flags, typeof(AclEntryFlag));
                }

                this.Flags_Renamed = flags;
                return(this);
            }
예제 #2
0
            /// <summary>
            /// Sets the permissions component of this builder. On return, the
            /// permissions component of this builder is a copy of the given set.
            /// </summary>
            /// <param name="perms">  the permissions component </param>
            /// <returns>  this builder
            /// </returns>
            /// <exception cref="ClassCastException">
            ///          if the set contains elements that are not of type {@code
            ///          AclEntryPermission} </exception>
            public Builder SetPermissions(Set <AclEntryPermission> perms)
            {
                if (perms.Count == 0)
                {
                    // EnumSet.copyOf does not allow empty set
                    perms = java.util.Collections.EmptySet();
                }
                else
                {
                    // copy and check for erroneous elements
                    perms = EnumSet.CopyOf(perms);
                    CheckSet(perms, typeof(AclEntryPermission));
                }

                this.Perms = perms;
                return(this);
            }
        private void InitSchedulerResourceTypes()
        {
            if (this.schedulerResourceTypes != null)
            {
                return;
            }
            YarnServiceProtos.RegisterApplicationMasterResponseProtoOrBuilder p = viaProto ?
                                                                                  proto : builder;
            IList <YarnServiceProtos.SchedulerResourceTypes> list = p.GetSchedulerResourceTypesList
                                                                        ();

            if (list.IsEmpty())
            {
                this.schedulerResourceTypes = EnumSet.NoneOf <YarnServiceProtos.SchedulerResourceTypes
                                                              >();
            }
            else
            {
                this.schedulerResourceTypes = EnumSet.CopyOf(list);
            }
        }
예제 #4
0
        /// <summary>Determine if this protocol can handle a particular URI.</summary>
        /// <remarks>
        /// Determine if this protocol can handle a particular URI.
        /// <p>
        /// Implementations should try to avoid looking at the local filesystem, but
        /// may look at implementation specific configuration options in the remote
        /// block of
        /// <code>local.getConfig()</code>
        /// using
        /// <code>remoteName</code>
        /// if the name
        /// is non-null.
        /// <p>
        /// The default implementation of this method matches the scheme against
        /// <see cref="GetSchemes()">GetSchemes()</see>
        /// , required fields against
        /// <see cref="GetRequiredFields()">GetRequiredFields()</see>
        /// , and optional fields against
        /// <see cref="GetOptionalFields()">GetOptionalFields()</see>
        /// , returning true only if all of the fields
        /// match the specification.
        /// </remarks>
        /// <param name="uri">address of the Git repository; never null.</param>
        /// <param name="local">
        /// the local repository that will communicate with the other Git
        /// repository. May be null if the caller is only asking about a
        /// specific URI and does not have a local Repository.
        /// </param>
        /// <param name="remoteName">
        /// name of the remote, if the remote as configured in
        /// <code>local</code>
        /// ; otherwise null.
        /// </param>
        /// <returns>true if this protocol can handle this URI; false otherwise.</returns>
        public virtual bool CanHandle(URIish uri, Repository local, string remoteName)
        {
            if (!GetSchemes().IsEmpty() && !GetSchemes().Contains(uri.GetScheme()))
            {
                return(false);
            }
            foreach (TransportProtocol.URIishField field in GetRequiredFields())
            {
                switch (field)
                {
                case TransportProtocol.URIishField.USER:
                {
                    if (uri.GetUser() == null || uri.GetUser().Length == 0)
                    {
                        return(false);
                    }
                    break;
                }

                case TransportProtocol.URIishField.PASS:
                {
                    if (uri.GetPass() == null || uri.GetPass().Length == 0)
                    {
                        return(false);
                    }
                    break;
                }

                case TransportProtocol.URIishField.HOST:
                {
                    if (uri.GetHost() == null || uri.GetHost().Length == 0)
                    {
                        return(false);
                    }
                    break;
                }

                case TransportProtocol.URIishField.PORT:
                {
                    if (uri.GetPort() <= 0)
                    {
                        return(false);
                    }
                    break;
                }

                case TransportProtocol.URIishField.PATH:
                {
                    if (uri.GetPath() == null || uri.GetPath().Length == 0)
                    {
                        return(false);
                    }
                    break;
                }

                default:
                {
                    return(false);

                    break;
                }
                }
            }
            ICollection <TransportProtocol.URIishField> canHave = EnumSet.CopyOf(GetRequiredFields
                                                                                     ());

            Sharpen.Collections.AddAll(canHave, GetOptionalFields());
            if (uri.GetUser() != null && !canHave.Contains(TransportProtocol.URIishField.USER
                                                           ))
            {
                return(false);
            }
            if (uri.GetPass() != null && !canHave.Contains(TransportProtocol.URIishField.PASS
                                                           ))
            {
                return(false);
            }
            if (uri.GetHost() != null && !canHave.Contains(TransportProtocol.URIishField.HOST
                                                           ))
            {
                return(false);
            }
            if (uri.GetPort() > 0 && !canHave.Contains(TransportProtocol.URIishField.PORT))
            {
                return(false);
            }
            if (uri.GetPath() != null && !canHave.Contains(TransportProtocol.URIishField.PATH
                                                           ))
            {
                return(false);
            }
            return(true);
        }