A visibility (for modules, class and properties)

Valid visibility are:

Note this class is basically an enum.

FIXME: use a real enum once user-defined enums are available

Introduced properties

private var _level: Int

nitc :: MVisibility :: _level

private var _to_s: String

nitc :: MVisibility :: _to_s

fun cs_icon(no_color: nullable Bool): String

nitc :: MVisibility :: cs_icon

Visibility icon
fun cs_visibility_color(string: String, no_color: nullable Bool): String

nitc :: MVisibility :: cs_visibility_color

Colorize string depending on the visibility
init defaultinit(to_s: String, level: Int)

nitc :: MVisibility :: defaultinit

private fun level: Int

nitc :: MVisibility :: level

private fun level=(level: Int)

nitc :: MVisibility :: level=

protected fun to_s=(to_s: String)

nitc :: MVisibility :: to_s=

fun tpl_class: Writable

nitc :: MVisibility :: tpl_class

Returns the visibility as a UML token

Redefined properties

redef fun <(other: OTHER): Bool

nitc $ MVisibility :: <

Is self give less visibility than other
redef type OTHER: MVisibility

nitc $ MVisibility :: OTHER

What self can be compared to?
redef type SELF: MVisibility

nitc $ MVisibility :: SELF

Type of this instance, automatically specialized in every class
redef fun to_s: String

nitc $ MVisibility :: to_s

User readable representation of self.

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
abstract fun <(other: OTHER): Bool

core :: Comparable :: <

Is self lesser than other?
fun <=(other: OTHER): Bool

core :: Comparable :: <=

not other < self
fun <=>(other: OTHER): Int

core :: Comparable :: <=>

-1 if <, +1 if > and 0 otherwise
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
fun >(other: OTHER): Bool

core :: Comparable :: >

other < self
fun >=(other: OTHER): Bool

core :: Comparable :: >=

not self < other
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type OTHER: Comparable

core :: Comparable :: OTHER

What self can be compared to?
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _level: Int

nitc :: MVisibility :: _level

private var _to_s: String

nitc :: MVisibility :: _to_s

fun clamp(min: OTHER, max: OTHER): OTHER

core :: Comparable :: clamp

Constraint self within [min..max]
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun cs_icon(no_color: nullable Bool): String

nitc :: MVisibility :: cs_icon

Visibility icon
fun cs_visibility_color(string: String, no_color: nullable Bool): String

nitc :: MVisibility :: cs_visibility_color

Colorize string depending on the visibility
init defaultinit(to_s: String, level: Int)

nitc :: MVisibility :: defaultinit

fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun is_between(c: OTHER, d: OTHER): Bool

core :: Comparable :: is_between

c <= self <= d
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
private fun level: Int

nitc :: MVisibility :: level

private fun level=(level: Int)

nitc :: MVisibility :: level=

fun max(other: OTHER): OTHER

core :: Comparable :: max

The maximum between self and other (prefers self if equals).
fun min(c: OTHER): OTHER

core :: Comparable :: min

The minimum between self and c (prefer self if equals)
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
protected fun to_s=(to_s: String)

nitc :: MVisibility :: to_s=

fun tpl_class: Writable

nitc :: MVisibility :: tpl_class

Returns the visibility as a UML token
package_diagram nitc::MVisibility MVisibility core::Comparable Comparable nitc::MVisibility->core::Comparable core::Object Object core::Comparable->core::Object ...core::Object ... ...core::Object->core::Object

Ancestors

interface Object

core :: Object

The root of the class hierarchy.

Parents

interface Comparable

core :: Comparable

The ancestor of class where objects are in a total order.

Class definitions

nitc $ MVisibility
# A visibility (for modules, class and properties)
# Valid visibility are:
#
#  * `intrude_visibility`
#  * `public_visibility`
#  * `protected_visibility`
#  * `none_visibility`
#  * `private_visiblity`
#
# Note this class is basically an enum.
# FIXME: use a real enum once user-defined enums are available
class MVisibility
	super Comparable
	redef type OTHER: MVisibility

	redef var to_s: String

	private var level: Int

	# TODO: private init because enumeration.

	# Is self give less visibility than other
	# none < private < protected < public < intrude
	redef fun <(other)
	do
		return self.level < other.level
	end
end
src/model/model_base.nit:120,1--147,3

nitc :: term_model $ MVisibility
redef class MVisibility
	# Visibility icon
	fun cs_icon(no_color: nullable Bool): String do
		var icon
		if self == private_visibility then
			icon = cs_visibility_color("-", no_color)
		else if self == protected_visibility then
			icon = cs_visibility_color("#", no_color)
		else
			icon = cs_visibility_color("+", no_color)
		end
		if no_color != null and no_color then return icon
		return icon.bold
	end

	# Colorize `string` depending on the visibility
	fun cs_visibility_color(string: String, no_color: nullable Bool): String do
		if no_color != null and no_color then return string
		if self == private_visibility then
			return string.red
		else if self == protected_visibility then
			return string.yellow
		else
			return string.green
		end
	end
end
src/doc/templates/term_model.nit:282,1--308,3

nitc :: astbuilder $ MVisibility
redef class MVisibility
	fun create_ast_representation(astbuilder: nullable ASTBuilder): AVisibility do
		if self.to_s == "public" then
			return new APublicVisibility
		else if self.to_s == "private" then
			return new APrivateVisibility
		else if self.to_s == "protected" then
			return new AProtectedVisibility
		else
			return new AIntrudeVisibility
		end
	end
end
src/astbuilder.nit:993,1--1005,3

nitc :: uml_class $ MVisibility
redef class MVisibility
	# Returns the visibility as a UML token
	#
	#    assert public_visibility.tpl_class == "+"
	#    assert private_visibility.tpl_class == "-"
	fun tpl_class: Writable do
		if self == private_visibility then
			return "-"
		else if self == protected_visibility then
			return "#"
		else if self == public_visibility then
			return "+"
		else
			return "+"
		end
	end
end
src/uml/uml_class.nit:156,1--172,3